SQLiteAsyncConnection UpdateWithChildren not available

*爱你&永不变心* 提交于 2021-02-07 22:21:02

问题


I am trying to implement a OneToMany relationship inside my PCL using SQLite.net. I have the async extensions package (SQLiteNetExtensions.Async) and I am basing the code on the example found in https://bitbucket.org/twincoders/sqlite-net-extensions. I am using SQLiteAsyncConnection but the UpdateWithChildren method does not seem to be available, only with 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:


When using SQLiteAsyncConnection, you have to use the async Nuget package, SQLiteNetExtensionsAsync.Extensions namespace and async versions of all the methods:

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);
}

Please note that all async methods return a Task that must be awaited or returned.



来源:https://stackoverflow.com/questions/37810919/sqliteasyncconnection-updatewithchildren-not-available

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!