当前位置: 首页>>代码示例>>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;未经允许,请勿转载。