Method CreateCommand
- Namespace
- Open.Database.Extensions
- Assembly
- Open.Database.Extensions.Core.dll
CreateCommand(IDbConnection, CommandType, string, int)
Creates an IDbCommand from a connection with the command type, text, and timeout already set.
public static IDbCommand CreateCommand(this IDbConnection connection, CommandType type, string commandText, int secondsTimeout = 60)
Parameters
connectionIDbConnectionThe connection 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. It is not associated with a transaction.
Remarks
The connection is not opened by this method; open it (see EnsureOpen(IDbConnection)) before executing the command.
Exceptions
- ArgumentNullException
connectionorcommandTextis null.- ArgumentException
commandTextis empty or white space.
CreateCommand(DbConnection, CommandType, string, int)
Creates a DbCommand from a DbConnection with the command type, text, and timeout already set.
public static DbCommand CreateCommand(this DbConnection connection, CommandType type, string commandText, int secondsTimeout = 60)
Parameters
connectionDbConnectionThe connection 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. It is not associated with a transaction.
Remarks
The connection is not opened by this method; open it (see EnsureOpen(IDbConnection)) before executing the command.
Exceptions
- ArgumentNullException
connectionorcommandTextis null.- ArgumentException
commandTextis empty or white space.