当前位置: 首页>>代码示例>>C#>>正文


C# Database.CloseSharedConnection方法代码示例

本文整理汇总了C#中Database.CloseSharedConnection方法的典型用法代码示例。如果您正苦于以下问题:C# Database.CloseSharedConnection方法的具体用法?C# Database.CloseSharedConnection怎么用?C# Database.CloseSharedConnection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Database的用法示例。


在下文中一共展示了Database.CloseSharedConnection方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: btnStartTest_Click

        private void btnStartTest_Click(object sender, EventArgs e)
        {
            IDatabase db = new Database("as400");

            // Use NPoco Query
            List<CustomerTable> customers = db.Fetch<CustomerTable>();
            customers.ForEach(c => Console.WriteLine(c.FirstName + @" - " + c.LastName));

            var u = new CustomerTable
            {
                FirstName = "Giulia",
                LastName = "Carbonci",
                PhoneNumber = 555555
            };

            db.Insert(u);

            u.LastName = "Carboni";
            db.Update(u);

            // Use NPoco Stored Procedure Extension
            Console.WriteLine(@"START USING PROCEDURE EXTENSION");

            var ts = new SPCustomerSelect { Key = 2 };
            IEnumerable<CustomerTable> storedResult = db.QueryStoredProcedure<CustomerTable, SPCustomerSelect>(ts);
            storedResult.ToList().ForEach(c => Console.WriteLine(c.FirstName + @" - " + c.LastName));
            Console.WriteLine(ts.ErrorMessage);
            db.CloseSharedConnection();
        }
开发者ID:asterd,项目名称:NPoco.iSeries,代码行数:29,代码来源:FrmTest.cs

示例2: ConstructorWithConnectionDBTypeAndIsolationLevel

        public void ConstructorWithConnectionDBTypeAndIsolationLevel()
        {
            var db = new Database(TestDatabase.Connection, new SqlServer2012DatabaseType(), IsolationLevel.ReadUncommitted);
            db.OpenSharedConnection();
            Assert.IsNotNull(db.Connection);
            Assert.IsTrue(db.Connection.State == ConnectionState.Open);
            Assert.AreEqual(typeof(SqlServer2012DatabaseType), db.DatabaseType.GetType());

            // Constructors using a Connection do not close the connection on close/displose
            db.CloseSharedConnection();
            Assert.IsNotNull(db.Connection);

            db.Dispose();
            Assert.IsNotNull(db.Connection);
        }
开发者ID:robertmilne,项目名称:NPoco,代码行数:15,代码来源:ConstructorTests.cs

示例3: ConstructorWithConnection

        public void ConstructorWithConnection()
        {
            var db = new Database(TestDatabase.Connection);
            db.OpenSharedConnection();
            Assert.IsNotNull(db.Connection);
            Assert.IsTrue(db.Connection.State == ConnectionState.Open);
            Assert.AreEqual(typeof (SqlServerDatabaseType), db.DatabaseType.GetType());

            // Constructors using a Connection do not close the connection on close/displose
            db.CloseSharedConnection();
            Assert.IsNotNull(db.Connection);

            db.Dispose();
            Assert.IsNotNull(db.Connection);
        }
开发者ID:robertmilne,项目名称:NPoco,代码行数:15,代码来源:ConstructorTests.cs

示例4: ConstructorWithConnectionStringAndDBProvider

        public void ConstructorWithConnectionStringAndDBProvider()
        {
            var dbType = new SqlServer2012DatabaseType();
            var provider = DbProviderFactories.GetFactory(dbType.GetProviderName());
            var db = new Database(TestDatabase.ConnectionString, provider);
            db.OpenSharedConnection();
            Assert.IsNotNull(db.Connection);
            Assert.IsTrue(db.Connection.State == ConnectionState.Open);
            Assert.AreEqual(typeof(SqlServerDatabaseType), db.DatabaseType.GetType());

            // Constructors using a Connection do not close the connection on close/displose
            db.CloseSharedConnection();
            Assert.IsNull(db.Connection);

            db.Dispose();
            Assert.IsNull(db.Connection);
        }
开发者ID:robertmilne,项目名称:NPoco,代码行数:17,代码来源:ConstructorTests.cs

示例5: ConstructorWithConnectionStringDBProviderAndSettings

        public void ConstructorWithConnectionStringDBProviderAndSettings()
        {
            var dbType = GetConfiguredDatabaseType();
            var provider = DbProviderFactories.GetFactory(dbType.GetProviderName());
            var db = new Database(TestDatabase.ConnectionString, provider, false);
            db.OpenSharedConnection();
            Assert.IsNotNull(db.Connection);
            Assert.IsTrue(db.Connection.State == ConnectionState.Open);
            Assert.AreEqual(dbType.GetType(), db.DatabaseType.GetType());

            // Constructors using a Connection do not close the connection on close/displose
            db.CloseSharedConnection();
            Assert.IsNull(db.Connection);

            db.Dispose();
            Assert.IsNull(db.Connection);
        }
开发者ID:aalex675,项目名称:NPoco,代码行数:17,代码来源:ConstructorTests.cs

示例6: ConstructorWithConnectionStringDBTypeAndSettings

        public void ConstructorWithConnectionStringDBTypeAndSettings()
        {
            var dbType = GetConfiguredDatabaseType();
            var db = new Database(TestDatabase.ConnectionString, dbType, IsolationLevel.ReadUncommitted, false);
            db.OpenSharedConnection();
            Assert.IsNotNull(db.Connection);
            Assert.IsTrue(db.Connection.State == ConnectionState.Open);
            Assert.AreEqual(dbType.GetType(), db.DatabaseType.GetType());

            // Constructors using a Connection do not close the connection on close/displose
            db.CloseSharedConnection();
            Assert.IsNull(db.Connection);

            db.Dispose();
            Assert.IsNull(db.Connection);
        }
开发者ID:aalex675,项目名称:NPoco,代码行数:16,代码来源:ConstructorTests.cs

示例7: ConstructorWithConnectionStringAndProviderName

        public void ConstructorWithConnectionStringAndProviderName()
        {
            var dbType = GetConfiguredDatabaseType();
            var db = new Database(TestDatabase.ConnectionString, dbType, SqlClientFactory.Instance);
            db.OpenSharedConnection();
            Assert.IsNotNull(db.Connection);
            Assert.IsTrue(db.Connection.State == ConnectionState.Open);
            Assert.AreEqual(dbType.GetType(), db.DatabaseType.GetType());

            // Constructors using a Connection do not close the connection on close/displose
            db.CloseSharedConnection();
            Assert.IsNull(db.Connection);

            db.Dispose();
            Assert.IsNull(db.Connection);
        }
开发者ID:schotime,项目名称:NPoco,代码行数:16,代码来源:ConstructorTests.cs


注:本文中的Database.CloseSharedConnection方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。