本文整理汇总了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();
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}