Car*_*arl 4 xamarin sqlite-net-extensions
我正在尝试使用 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
}
Run Code Online (Sandbox Code Playgroud)
使用时SQLiteAsyncConnection,您必须使用async 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);
}
Run Code Online (Sandbox Code Playgroud)
请注意,所有异步方法都返回Task必须等待或返回的 a。
| 归档时间: |
|
| 查看次数: |
2161 次 |
| 最近记录: |