SQLiteAsyncConnection UpdateWithChildren不可用

时间:2016-06-14 11:37:45

标签: xamarin sqlite-net-extensions

我正在尝试使用SQLite.net在我的PCL中实现OneToMany关系。我有async扩展包(SQLiteNetExtensions.Async),我的代码基于https://bitbucket.org/twincoders/sqlite-net-extensions中的示例。我使用的是SQLiteAsyncConnection,但UpdateWithChildren方法似乎不可用,只能使用SQLiteConnection。

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
}

1 个答案:

答案 0 :(得分:3)

使用SQLiteAsyncConnection时,您必须使用async Nuget packageSQLiteNetExtensionsAsync.Extensions命名空间和所有方法的异步版本:

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

相关问题