2016-06-14 17 views
1

SQLite.netを使用して自分のPCL内でOneToMany関係を実装しようとしています。私は非同期拡張パッケージ(SQLiteNetExtensions.Async)を持っており、https://bitbucket.org/twincoders/sqlite-net-extensionsにある例のコードをベースにしています。私はSQLiteAsyncConnectionを使用していますが、UpdateWithChildrenメソッドはSQLiteConnectionでしか使用できないようです。SQLiteAsyncConnection UpdateWithChildrenが利用できません

using SQLite.Net; 
using SQLite.Net.Async; 
using SQLite.Net.Interop; 
using SQLiteNetExtensionsAsync.Extensions; 

private readonly SQLiteAsyncConnection conn; 
public ActivityRepository(ISQLitePlatform platform, string dbPath) 
{ 
    var connectionFactory = new Func<SQLiteConnectionWithLock>(() => new SQLiteConnectionWithLock(platform, new SQLiteConnectionString(dbPath, storeDateTimeAsTicks: true))); 
    conn = new SQLiteAsyncConnection(connectionFactory); 
} 
public Task method(object object) { 
    return conn.UpdateWithChildrenAsync(object); 
} 

すべての非同期メソッドを待つか、返却されなければならないTaskを返すことに注意してください:

using SQLite.Net; 
using SQLite.Net.Async; 
using SQLite.Net.Interop; 
using SQLiteNetExtensions.Extensions; 

private readonly SQLiteAsyncConnection conn; 
public ActivityRepository(ISQLitePlatform platform, string dbPath) 
{ 
    var connectionFactory = new Func<SQLiteConnectionWithLock>(() => new SQLiteConnectionWithLock(platform, new SQLiteConnectionString(dbPath, storeDateTimeAsTicks: true))); 
    conn = new SQLiteAsyncConnection(connectionFactory); 
} 
public void method(object object) { 
    conn.UpdateWithChildren(object); --function not available 
} 

答えて

2

SQLiteAsyncConnectionを使用して、あなたはasync Nuget packageSQLiteNetExtensionsAsync.Extensions名前空間とすべてのメソッドの非同期バージョンを使用する必要があります。

+0

ありがとう、非同期パッケージがインストールされていましたが、私はUpdateWithChildrenAsyncメソッドを使用していませんでした。 – Carl