當前位置: 首頁>>代碼示例>>C#>>正文


C# Database.OpenSharedConnection方法代碼示例

本文整理匯總了C#中PetaPoco.Database.OpenSharedConnection方法的典型用法代碼示例。如果您正苦於以下問題:C# Database.OpenSharedConnection方法的具體用法?C# Database.OpenSharedConnection怎麽用?C# Database.OpenSharedConnection使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在PetaPoco.Database的用法示例。


在下文中一共展示了Database.OpenSharedConnection方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: CreateDB

		public void CreateDB()
		{
			db = new Database(_connectionStringName);
			db.OpenSharedConnection();		// <-- Wow, this is crucial to getting SqlCE to perform.
			db.Execute(Utils.LoadTextResource(string.Format("PetaPoco.Tests.{0}_init.sql", _connectionStringName)));
		}
開發者ID:kakakakaka1230,項目名稱:PetaPoco,代碼行數:6,代碼來源:Tests.cs

示例2: HaveDb

        private static Database HaveDb()
        {
			string message = "";
			if ((UseFileSystem == false) && (_db == null))
			{
				InitDb();

				string rootPath = IOManager.RootDirectory;
				string dataPath = IOManager.Combine(rootPath, "App_Data");
				if (ConnectionString.Contains("|DataDirectory|") == true)
				{
					ConnectionString = ConnectionString.Replace("|DataDirectory|", dataPath + IOManager.DirectorySeparator);
				}
				bool checkDb = true;
				if ((ProviderNameFactory.ToUpper() == AppCommon.SQLiteProviderNameFactory.ToUpper()) && (ConnectionString.Contains("AutoFill") == false))
				{
						string sqliteDbPath = "";
					int idxOfSemiColon =ConnectionString.IndexOf(";");
					if (idxOfSemiColon > -1)
					{
						int idxOfEqual = ConnectionString.IndexOf("=");
						sqliteDbPath = ConnectionString.Substring(idxOfEqual + 1, idxOfSemiColon - idxOfEqual -1);
					}
					else
					{
						sqliteDbPath = ConnectionString.Substring(ConnectionString.IndexOf("=") + 1);
					}
					if (IOManager.CachedFileExists(sqliteDbPath, true, true) ==false)
					{
						checkDb =false ;
						LogManager.Log(LogLevel.Critical, "DataSource-HaveDb", "Sqlite Db Not found in Path [" + sqliteDbPath + "]");
					}                       
				}
				if (checkDb == true)
				{
					_db = DataStore.HaveDb(ConnectionString, ProviderNameFactory, out message);
					if (_db != null) {
                        _db.OnDBException -= new PetaPoco.DBException(OnDBException);
                        _db.OnDBException += new PetaPoco.DBException(OnDBException);
                        if (ProviderNameFactory == AppCommon.SQLiteProviderNameFactory)
                        {
                            _db.KeepConnectionAlive = true;
                            UseSharedConnection = true;
                            //_db.Execute("PRAGMA journal_mode=WAL;");
                            //_db.Execute("PRAGMA journal_mode=DELETE;");
                        }
                        if (ProviderNameFactory == AppCommon.MySQLProviderNameFactory)
                        {
                            _db.KeepConnectionAlive = false;
                            UseSharedConnection = false;
                            //_db.Execute("set wait_timeout=28800");
                            //_db.Execute("set interactive_timeout=28800");
                            //_db.Execute("set net_write_timeout=999");
                        }
                        if (UseSharedConnection == true)
                        {
                            _db.OpenSharedConnection();
                        }
					}
				}
			}
			if (_db == null) {
				if (UseFileSystem ==false)
				{
					LogManager.Log(LogLevel.Critical, "Priya.InfoList.DataSource-HaveDb", "Have Db is false for " + DbName + "[" + message + "]");
				}
				else
				{
					LogManager.Log(LogLevel.Critical, "Priya.InfoList.DataSource-HaveDb", "Have Db is false for " + DbName + ". Use FileSystem is true");
				}
			}
            return _db;
        }
開發者ID:Srid68,項目名稱:Priya.InfoList,代碼行數:73,代碼來源:DataSource.cs


注:本文中的PetaPoco.Database.OpenSharedConnection方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。