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

JMa*_*Man 7 database-connection xamarin sqlite-net

我以前SQLiteConnection在我的共享项目中打开了以下内容:

var conn = new SQLiteConnection("MyDb.db3");
Run Code Online (Sandbox Code Playgroud)

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

    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);
Run Code Online (Sandbox Code Playgroud)

我无法找到有关如何在我的共享库中实现此功能的任何示例/文档.

JMa*_*Man 11

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

我必须在de平台特定库而不是共享库中实现它.

new SQLiteConnection(new SQLite.Net.Platform.XamarinAndroid.SQLitePlatformAndroid(), Path.Combine(path, db));
Run Code Online (Sandbox Code Playgroud)