Here are the examples of the csharp api class System.Data.Common.DbCommand.OpenConnection() taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
7 Examples
0
1. Example
View licensepublic static DbTransaction BeginTransaction( this DbCommand dbCommand ) { dbCommand.OpenConnection(); DbTransaction transaction = dbCommand.Connection.BeginTransaction(); dbCommand.SetTransaction( transaction ); return transaction; }
0
2. Example
View licensepublic static DbTransaction BeginTransaction( this DbCommand dbCommand, IsolationLevel isolationLevel ) { dbCommand.OpenConnection(); DbTransaction transaction = dbCommand.Connection.BeginTransaction( isolationLevel ); dbCommand.SetTransaction( transaction ); return transaction; }
0
3. Example
View licensepublic static int ExecuteNonQuery( this DatabaseCommand databaseCommand, bool keepConnectionOpen = false ) { int numberOfRowsAffected; try { Sequelocity.ConfigurationSettings.EventHandlers.InvokeDatabaseCommandPreExecuteEventHandlers( databaseCommand ); databaseCommand.DbCommand.OpenConnection(); numberOfRowsAffected = databaseCommand.DbCommand.ExecuteNonQuery(); Sequelocity.ConfigurationSettings.EventHandlers.InvokeDatabaseCommandPostExecuteEventHandlers( databaseCommand ); } catch ( Exception exception ) { Sequelocity.ConfigurationSettings.EventHandlers.InvokeDatabaseCommandUnhandledExceptionEventHandlers( exception, databaseCommand ); throw; } finally { if ( keepConnectionOpen == false ) { databaseCommand.DbCommand.CloseAndDispose(); databaseCommand.DbCommand = null; } } return numberOfRowsAffected; }
0
4. Example
View licensepublic static object ExecuteScalar( this DatabaseCommand databaseCommand, bool keepConnectionOpen = false ) { object returnValue; try { Sequelocity.ConfigurationSettings.EventHandlers.InvokeDatabaseCommandPreExecuteEventHandlers( databaseCommand ); databaseCommand.DbCommand.OpenConnection(); returnValue = databaseCommand.DbCommand.ExecuteScalar(); if ( returnValue == DBNull.Value ) returnValue = null; Sequelocity.ConfigurationSettings.EventHandlers.InvokeDatabaseCommandPostExecuteEventHandlers( databaseCommand ); } catch ( Exception exception ) { Sequelocity.ConfigurationSettings.EventHandlers.InvokeDatabaseCommandUnhandledExceptionEventHandlers( exception, databaseCommand ); throw; } finally { if ( keepConnectionOpen == false ) { databaseCommand.DbCommand.CloseAndDispose(); databaseCommand.DbCommand = null; } } return returnValue; }
0
5. Example
View licensepublic static DataSet ExecuteToDataSet( this DatabaseCommand databaseCommand, bool keepConnectionOpe/n ..... /n //View Source file for more details /n }
0
6. Example
View licensepublic static void ExecuteReader( this DatabaseCommand databaseCommand, Action<IDataRecord> dataRecordCallback, bool keepConnectionOpen = false ) { try { Sequelocity.ConfigurationSettings.EventHandlers.InvokeDatabaseCommandPreExecuteEventHandlers( databaseCommand ); databaseCommand.DbCommand.OpenConnection(); using ( DbDataReader dbDataReader = databaseCommand.DbCommand.ExecuteReader() ) { while ( dbDataReader.HasRows ) { while ( dbDataReader.Read() ) { dataRecordCallback.Invoke( dbDataReader ); } dbDataReader.NextResult(); } } Sequelocity.ConfigurationSettings.EventHandlers.InvokeDatabaseCommandPostExecuteEventHandlers( databaseCommand ); } catch ( Exception exception ) { Sequelocity.ConfigurationSettings.EventHandlers.InvokeDatabaseCommandUnhandledExceptionEventHandlers( exception, databaseCommand ); throw; } finally { if ( keepConnectionOpen == false ) { databaseCommand.DbCommand.CloseAndDispose(); databaseCommand.DbCommand = null; } } }
0
7. Example
View licensepublic static IEnumerable<T> ExecuteReader<T>( this DatabaseCommand databaseCommand, Fun/n ..... /n //View Source file for more details /n }