本文整理汇总了C#中DBConnection.ExecuteWithConnectionOpen方法的典型用法代码示例。如果您正苦于以下问题:C# DBConnection.ExecuteWithConnectionOpen方法的具体用法?C# DBConnection.ExecuteWithConnectionOpen怎么用?C# DBConnection.ExecuteWithConnectionOpen使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DBConnection
的用法示例。
在下文中一共展示了DBConnection.ExecuteWithConnectionOpen方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: setupNewDatabase
/*
private void setupNewDatabase() {
var script = @"
CREATE TABLE global_ints(
ParameterName VARCHAR( 50 )
PRIMARY KEY,
ParameterValue INT
NOT NULL
);
INSERT INTO global_ints VALUES( 'LineMarker', 0 );
CREATE TABLE main_sequence(
MainSequenceId INT
AUTO_INCREMENT
PRIMARY KEY
);
";
}
*/
public void ExecuteDbMethod( Action<DBConnection> method )
{
executeMethodWithDbExceptionHandling(
() => {
var connection = new DBConnection( new MySqlInfo( ( info as DatabaseInfo ).SecondaryDatabaseName, info.Database, false ) );
connection.ExecuteWithConnectionOpen( () => method( connection ) );
} );
}
示例2: executeDbMethodWithSpecifiedDatabaseInfo
private void executeDbMethodWithSpecifiedDatabaseInfo( OracleInfo info, Action<DBConnection> method )
{
executeMethodWithDbExceptionHandling(
delegate {
// Before we disabled pooling, we couldn't repeatedly perform Update Data operations since users with open connections can't be dropped.
var connection =
new DBConnection(
new OracleInfo(
( info as DatabaseInfo ).SecondaryDatabaseName,
info.DataSource,
info.UserAndSchema,
info.Password,
false,
info.SupportsLinguisticIndexes ) );
connection.ExecuteWithConnectionOpen( () => method( connection ) );
} );
}
示例3: executeDbMethodWithSpecifiedDatabaseInfo
private void executeDbMethodWithSpecifiedDatabaseInfo( SqlServerInfo info, Action<DBConnection> method )
{
executeMethodWithDbExceptionHandling(
() => {
var connection =
new DBConnection(
new SqlServerInfo(
( info as DatabaseInfo ).SecondaryDatabaseName,
info.Server,
info.LoginName,
info.Password,
info.Database,
false,
info.FullTextCatalog ) );
connection.ExecuteWithConnectionOpen( () => method( connection ) );
} );
}