SQLiteAsyncConnection UpdateWithChildren不可用

卡尔

我正在尝试使用SQLite.net在我的PCL中实现OneToMany关系。我有异步扩展包(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
}
redent84

使用时SQLiteAsyncConnection,必须使用所有方法异步Nuget包SQLiteNetExtensionsAsync.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必须等待或返回的。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章