将 SQLite-net 升级到 SQLite.net - 创建 SQLiteConnection

upgrading SQLite-net to SQLite.net - create SQLiteConnection

我曾经在我的共享项目中打开我的SQLiteConnection如下:

var conn = new SQLiteConnection("MyDb.db3");

构造函数已更改为以下签名:

    public SQLiteConnection(ISQLitePlatform sqlitePlatform, string databasePath, bool storeDateTimeAsTicks = true, IBlobSerializer serializer = null, IDictionary<string, TableMapping> tableMappings = null, IDictionary<Type, string> extraTypeMappings = null, IContractResolver resolver = null);
    public SQLiteConnection(ISQLitePlatform sqlitePlatform, string databasePath, SQLiteOpenFlags openFlags, bool storeDateTimeAsTicks = true, IBlobSerializer serializer = null, IDictionary<string, TableMapping> tableMappings = null, IDictionary<Type, string> extraTypeMappings = null, IContractResolver resolver = null);

我无法在我的共享库中找到任何关于如何实现它的 examples/documentation。

一旦找到就很容易了。命名空间 SQLite.Net.Platform 包含 ISQLitePlatform 接口的实现。

我必须在特定于平台的库而不是共享库中实现它。

new SQLiteConnection(new SQLite.Net.Platform.XamarinAndroid.SQLitePlatformAndroid(), Path.Combine(path, db));