在使用 sqlite-net + async 时设置 Sqlite ThreadingMode

本文关键字:设置 Sqlite ThreadingMode async sqlite-net | 更新日期: 2023-09-27 18:37:16

我正在尝试在我的Xamarin.iOS项目中将Sqlite ThreadMode设置为序列化。使用经典的 Sqlite,可以在连接类上找到此方法:

SqliteConnection.SetConfig(SQLiteConfig.Serialized);

但是我正在使用sqlite-net(+异步),找不到设置此配置属性的方法。

有什么建议吗?

在使用 sqlite-net + async 时设置 Sqlite ThreadingMode

好的,我不得不将SQLite-Net(和SQLite-Net-PCL等)更新到2.5。

然后,可以通过特定于平台的实现访问此选项:

public Repository(IPlatform platform)
    {
        _platform = platform;
        _platform.SqlitePlatform.SQLiteApi.Config(ConfigOption.Serialized);
        _db = new SQLiteAsyncConnection(() =>
            new SQLite.Net.SQLiteConnectionWithLock(
            _platform.SqlitePlatform,
            new SQLite.Net.SQLiteConnectionString(_platform.DatabasePath, true)));
    }