Table of Contents

Class DbCommandExtensions

Namespace
Utils.Data
Assembly
Utils.Data.dll

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

dbCommand IDbCommand

The command to modify.

name string

Name of the parameter.

dbType DbType

Type of the parameter.

value object

Value 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

dbCommand IDbCommand

The command to modify.

name string

Name of the parameter.

value object

Value 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

dbCommand IDbCommand

The command for which the parameter is created.

name string

Name of the parameter.

dbType DbType

The DbType of the parameter.

value object

Value 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

dbCommand DbCommand

The command on which to set the CommandText.

syntaxOptions SqlSyntaxOptions

Syntax options controlling parameter prefixes.

interpolator SqlBuilderInterpolator

Interpolator 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

dbCommand DbCommand

The command on which to set the CommandText.

interpolator SqlBuilderInterpolator

Interpolator 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

dbCommand IDbCommand

The command on which to set the CommandText.

syntaxOptions SqlSyntaxOptions

Syntax options controlling parameter prefixes.

interpolator SqlBuilderInterpolator

Interpolator 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

dbCommand IDbCommand

The command on which to set the CommandText.

interpolator SqlBuilderInterpolator

Interpolator that builds the SQL and parameters.

Returns

IDbCommand

The same command instance for chaining.