Method CreateCommand
- Namespace
- Open.Database.Extensions
- Assembly
- Open.Database.Extensions.MSSqlClient.dll
CreateCommand(SqlTransaction, CommandType, string, int)
Creates a SqlCommand enlisted in a transaction, on the transaction's connection, with the command type, text, and timeout already set.
public static SqlCommand CreateCommand(this SqlTransaction transaction, CommandType type, string commandText, int secondsTimeout = 60)
Parameters
transactionSqlTransactionThe 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
- SqlCommand
A new SqlCommand that the caller owns and disposes.
Exceptions
- ArgumentNullException
transactionorcommandTextis null.- ArgumentException
commandTextis empty or white space.