私はSQLiteデータベースにデータを保存したいので、SQLite.Net-PLCナゲットをインストールして、アンドロイドとiOSで接続を作成した後、SQLite.Net.Async- PLCのnugetは、私は関数を定義リポジトリ作成:挿入、更新などを削除します。また、私はこのようなテーブルを作成Xamarin Forms SQLite
public Task<int> InsertAsync(T entity) {
return _connection.InsertAsync(entity);
}
:私のページで
public Repository(ISQLiteConnection connectionService) {
_connectionService = connectionService;
_connection = _connectionService.GetConnection();
_connection.CreateTableAsync<T>();
}
を私が挿入したいですテーブル:
ISQLiteConnection connectionService = DependencyService.Get<ISQLiteConnection>();
var activityRepo = new Repository<Activity>(connectionService);
await activityRepo.InsertAsync(activity);
それは私にこのエラーを与える:SQLite.Net.SQLiteException:いいえ、そのようなテーブル:活動
私はそれがテーブルを作成していますし、エラーが挿入非同期なステートメントにポップアップ、ブレークポイントを置きます。
_connection.CreateTableAsync<T>();
警告は、このコールが待たれていないことを明確に述べるでしょう:
テーブルも非同期で作成されています。あなたはそれを待ってみましたか?テーブルがまだ作成されていない可能性があります。 – Blacktempel
私は、別の関数で作成テーブルを配置しようとしているし、awaitで関数を呼び出すが、私にこのエラーを与える:System.NotSupportedException:System.Collections.ObjectModel.ObservableCollection'1 [System.String ] – Mireille