C# 如何在Xamarin iOS SQLite中添加SQLiteOpenFlags.FullMutex标志
我试图在我的项目中使用SQLite数据库,在Xamarin论坛中使用多个线程。它们在其中创建以下静态类:C# 如何在Xamarin iOS SQLite中添加SQLiteOpenFlags.FullMutex标志,c#,multithreading,sqlite,xamarin,xamarin.ios,C#,Multithreading,Sqlite,Xamarin,Xamarin.ios,我试图在我的项目中使用SQLite数据库,在Xamarin论坛中使用多个线程。它们在其中创建以下静态类: public static class Data { static readonly string Path = System.IO.Path.Combine (Environment.GetFolderPath (Environment.SpecialFolder.MyDocuments), "database.db"); static SQLite.SQLiteConne
public static class Data {
static readonly string Path = System.IO.Path.Combine (Environment.GetFolderPath (Environment.SpecialFolder.MyDocuments), "database.db");
static SQLite.SQLiteConnection connection;
public static SQLite.SQLiteConnection Connection
{
get {
if (connection == null) {
connection = new SQLiteConnection (Path,SQLiteOpenFlags.ReadWrite | SQLiteOpenFlags.Create | SQLiteOpenFlags.FullMutex , true);
}
return connection;
}
}
}
我正在尝试实现这一点,但是我当前使用的连接方法具有不同的方法签名。我想这是因为我在用PCL。我目前使用以下方式连接:
SQLiteConnection db = new SQLiteConnection (new SQLitePlatformIOS (), AppController._dbPath, false, null);
如何添加SQLiteOpenFlags.ReadWrite | SQLiteOpenFlags.Create | SQLiteOpenFlags.FullMutex
,以便使用以下连接:
new SQLiteConnection (Path,SQLiteOpenFlags.ReadWrite | SQLiteOpenFlags.Create | SQLiteOpenFlags.FullMutex , true)
我已经厌倦了以下内容,但它失败了,因为它与所需的方法签名不匹配
_connection = new SQLiteConnection (new SQLitePlatformIOS (),Path,false,null,SQLiteOpenFlags.ReadWrite | SQLiteOpenFlags.Create | SQLiteOpenFlags.FullMutex);
我还在我的PCL项目中使用SQLite,我有下面的方法,这就是您试图找到的方法
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);
公共SQLiteConnection(ISQLitePlatform sqlitePlatform
,字符串数据库路径
,SQLiteOpenFlags openFlags
,bool storeDateTimeAsTicks=true
,IBlobSerializer序列化程序=null
,IDictionary tableMappings=null
,IDictionary extraTypeMappings=null
,IContractResolver-resolver=null);
我使用的PCL SQLite版本是3.0.5,您可以找到Nuget。
如果感兴趣,您可以获得Async
版本