Method CreateCommand
- Namespace
- Open.Database.Extensions
- Assembly
- Open.Database.Extensions.Core.dll
CreateCommand(IDbTransaction, CommandType, string, int)
Creates an IDbCommand on the transaction's connection, enlisted in the transaction, with the command type, text, and timeout already set.
public static IDbCommand CreateCommand(this IDbTransaction transaction, CommandType type, string commandText, int secondsTimeout = 60)
Parameters
transactionIDbTransactionThe transaction to create the command from.
typeCommandTypeThe command type: Text, StoredProcedure, or TableDirect.
commandTextstringThe command text, or the stored procedure name when
typeis StoredProcedure.secondsTimeoutintThe number of seconds to wait before the command times out. The default is 60 seconds.
Returns
- IDbCommand
A new IDbCommand that the caller owns and disposes. Its Transaction is
transaction.
Exceptions
- ArgumentException
commandTextis empty or white space.- ArgumentNullException
transactionorcommandTextis null.- InvalidOperationException
The transaction has no connection.
CreateCommand(DbTransaction, CommandType, string, int)
Creates a DbCommand on the transaction's connection, enlisted in the transaction, with the command type, text, and timeout already set.
public static DbCommand CreateCommand(this DbTransaction transaction, CommandType type, string commandText, int secondsTimeout = 60)
Parameters
transactionDbTransactionThe transaction to create the command from.
typeCommandTypeThe command type: Text, StoredProcedure, or TableDirect.
commandTextstringThe command text, or the stored procedure name when
typeis StoredProcedure.secondsTimeoutintThe number of seconds to wait before the command times out. The default is 60 seconds.
Returns
- DbCommand
A new DbCommand that the caller owns and disposes. Its Transaction is
transaction.
Exceptions
- ArgumentException
commandTextis empty or white space.- ArgumentNullException
transactionorcommandTextis null.- InvalidOperationException
The transaction has no connection.