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

时间:2015-05-25 06:47:37

标签: xamarin database-connection sqlite-net

我曾经在我的共享项目中打开我的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);

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

1 个答案:

答案 0 :(得分:11)

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

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

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