Class DbCommandExtensions
Provides helper methods to ease parameter creation for IDbCommand instances.
public static class DbCommandExtensions
- Inheritance
-
DbCommandExtensions
- Inherited Members
Methods
AddParameter(IDbCommand, string, DbType, object)
Creates a parameter, adds it to the command and returns it.
public static IDbDataParameter AddParameter(this IDbCommand dbCommand, string name, DbType dbType, object value)
Parameters
dbCommandIDbCommandThe command to modify.
namestringName of the parameter.
dbTypeDbTypeType of the parameter.
valueobjectValue assigned to the parameter.
Returns
- IDbDataParameter
The parameter that was added to the command.
AddParameter(IDbCommand, string, object)
Adds a parameter to the command, inferring its type from the provided value.
public static IDbDataParameter AddParameter(this IDbCommand dbCommand, string name, object value)
Parameters
dbCommandIDbCommandThe command to modify.
namestringName of the parameter.
valueobjectValue assigned to the parameter.
Returns
- IDbDataParameter
The parameter that was added to the command.
CreateParameter(IDbCommand, string, DbType, object)
Creates a new parameter and configures it with the provided metadata.
public static IDbDataParameter CreateParameter(this IDbCommand dbCommand, string name, DbType dbType, object value)
Parameters
dbCommandIDbCommandThe command for which the parameter is created.
namestringName of the parameter.
dbTypeDbTypeThe DbType of the parameter.
valueobjectValue of the parameter.
Returns
- IDbDataParameter
The configured parameter.
SetCommandText(DbCommand, SqlSyntaxOptions, SqlBuilderInterpolator)
Sets the CommandText using an interpolated SQL builder and custom syntax options.
public static DbCommand SetCommandText(this DbCommand dbCommand, SqlSyntaxOptions syntaxOptions, SqlBuilderInterpolator interpolator)
Parameters
dbCommandDbCommandThe command on which to set the CommandText.
syntaxOptionsSqlSyntaxOptionsSyntax options controlling parameter prefixes.
interpolatorSqlBuilderInterpolatorInterpolator that builds the SQL and parameters.
Returns
- DbCommand
The same command instance for chaining.
SetCommandText(DbCommand, SqlBuilderInterpolator)
Sets the CommandText using an interpolated SQL builder.
public static DbCommand SetCommandText(this DbCommand dbCommand, SqlBuilderInterpolator interpolator)
Parameters
dbCommandDbCommandThe command on which to set the CommandText.
interpolatorSqlBuilderInterpolatorInterpolator that builds the SQL and parameters.
Returns
- DbCommand
The same command instance for chaining.
SetCommandText(IDbCommand, SqlSyntaxOptions, SqlBuilderInterpolator)
Sets the CommandText using an interpolated SQL builder and custom syntax options.
public static IDbCommand SetCommandText(this IDbCommand dbCommand, SqlSyntaxOptions syntaxOptions, SqlBuilderInterpolator interpolator)
Parameters
dbCommandIDbCommandThe command on which to set the CommandText.
syntaxOptionsSqlSyntaxOptionsSyntax options controlling parameter prefixes.
interpolatorSqlBuilderInterpolatorInterpolator that builds the SQL and parameters.
Returns
- IDbCommand
The same command instance for chaining.
SetCommandText(IDbCommand, SqlBuilderInterpolator)
Sets the CommandText using an interpolated SQL builder.
public static IDbCommand SetCommandText(this IDbCommand dbCommand, SqlBuilderInterpolator interpolator)
Parameters
dbCommandIDbCommandThe command on which to set the CommandText.
interpolatorSqlBuilderInterpolatorInterpolator that builds the SQL and parameters.
Returns
- IDbCommand
The same command instance for chaining.