gpt4 book ai didi

xamarin - SQLiteAsyncConnection UpdateWithChildren 不可用

转载 作者:行者123 更新时间:2023-12-02 15:09:12 28 4
gpt4 key购买 nike

我正在尝试使用 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
}

最佳答案

使用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

关于xamarin - SQLiteAsyncConnection UpdateWithChildren 不可用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37810919/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com