Method Command
- Namespace
- Open.Database.Extensions
- Assembly
- Open.Database.Extensions.MSSqlClient.dll
Command(SqlConnection, string, CommandType)
Creates an ExpressiveSqlCommand that executes on the given connection.
public static ExpressiveSqlCommand Command(this SqlConnection connection, string command, CommandType type = CommandType.Text)
Parameters
connectionSqlConnectionThe connection to execute on. It is opened only if it is closed, closed again afterwards if the command opened it, and never disposed.
commandstringThe command text, or the stored procedure name when
typeis StoredProcedure.typeCommandTypeThe command type. The default is Text.
Returns
- ExpressiveSqlCommand
A new ExpressiveSqlCommand to configure with parameters and then execute.
Exceptions
- ArgumentNullException
connectionorcommandis null.- ArgumentException
commandis empty or white space.
Command(SqlTransaction, string, CommandType)
Creates an ExpressiveSqlCommand that executes within the given transaction.
public static ExpressiveSqlCommand Command(this SqlTransaction transaction, string command, CommandType type = CommandType.Text)
Parameters
transactionSqlTransactionThe transaction to execute in. The command runs on the transaction's Connection.
commandstringThe command text, or the stored procedure name when
typeis StoredProcedure.typeCommandTypeThe command type. The default is Text.
Returns
- ExpressiveSqlCommand
A new ExpressiveSqlCommand to configure with parameters and then execute.
Exceptions
- ArgumentNullException
transactionorcommandis null.- ArgumentException
commandis empty or white space.
Command(IDbConnectionFactory<SqlConnection>, string, CommandType)
Creates an ExpressiveSqlCommand that creates a new connection from a connection factory for every execution.
public static ExpressiveSqlCommand Command(this IDbConnectionFactory<SqlConnection> connectionSource, string command, CommandType type = CommandType.Text)
Parameters
connectionSourceIDbConnectionFactory<SqlConnection>The factory that creates the connections. Each execution creates a connection, opens it if needed, and disposes it when finished.
commandstringThe command text, or the stored procedure name when
typeis StoredProcedure.typeCommandTypeThe command type. The default is Text.
Returns
- ExpressiveSqlCommand
A new ExpressiveSqlCommand to configure with parameters and then execute.
Exceptions
- ArgumentNullException
connectionSourceorcommandis null.- ArgumentException
commandis empty or white space.
Command(IDbConnectionPool<SqlConnection>, string, CommandType)
Creates an ExpressiveSqlCommand that takes its connections from a connection pool.
public static ExpressiveSqlCommand Command(this IDbConnectionPool<SqlConnection> connectionSource, string command, CommandType type = CommandType.Text)
Parameters
connectionSourceIDbConnectionPool<SqlConnection>The pool to take connections from. Each execution takes one, opens it if needed, and gives it back when finished.
commandstringThe command text, or the stored procedure name when
typeis StoredProcedure.typeCommandTypeThe command type. The default is Text.
Returns
- ExpressiveSqlCommand
A new ExpressiveSqlCommand to configure with parameters and then execute.
Exceptions
- ArgumentNullException
connectionSourceorcommandis null.- ArgumentException
commandis empty or white space.
Command(Func<SqlConnection>, string, CommandType)
Creates an ExpressiveSqlCommand that invokes a function to create a new connection for every execution.
public static ExpressiveSqlCommand Command(this Func<SqlConnection> connectionSource, string command, CommandType type = CommandType.Text)
Parameters
connectionSourceFunc<SqlConnection>The function that creates the connections. Each execution invokes it, opens the connection if needed, and disposes it when finished.
commandstringThe command text, or the stored procedure name when
typeis StoredProcedure.typeCommandTypeThe command type. The default is Text.
Returns
- ExpressiveSqlCommand
A new ExpressiveSqlCommand to configure with parameters and then execute.
Exceptions
- ArgumentNullException
connectionSourceorcommandis null.- ArgumentException
commandis empty or white space.