Table of Contents

Method AddParameter

Namespace
Open.Database.Extensions
Assembly
Open.Database.Extensions.Core.dll

AddParameter(IDbCommand, string, object?)

Adds a parameter with the given name and value to the command, leaving the provider to infer the database type from the value.

public static IDbDataParameter AddParameter(this IDbCommand target, string name, object? value = null)

Parameters

target IDbCommand

The command to add the parameter to.

name string

The name of the parameter.

value object

The value of the parameter. It is assigned as given: a null is not converted to Value, and providers differ in how they treat it, so pass Value to send a database null.

Returns

IDbDataParameter

The created parameter, which has already been added to the command's parameter collection.

Exceptions

ArgumentNullException

target or name is null.

ArgumentException

name is empty or white space.

AddParameter(IDbCommand, string, string?)

Adds a string parameter (String) with the given name and value to the command.

public static IDbDataParameter AddParameter(this IDbCommand target, string name, string? value)

Parameters

target IDbCommand

The command to add the parameter to.

name string

The name of the parameter.

value string

The value of the parameter. A null is assigned as given and is not converted to Value.

Returns

IDbDataParameter

The created parameter, which has already been added to the command's parameter collection.

Exceptions

ArgumentNullException

target or name is null.

ArgumentException

name is empty or white space.

See Also

AddParameter(IDbCommand, string, int)

Adds a 32-bit integer parameter (Int32) with the given name and value to the command.

public static IDbDataParameter AddParameter(this IDbCommand target, string name, int value)

Parameters

target IDbCommand

The command to add the parameter to.

name string

The name of the parameter.

value int

The value of the parameter.

Returns

IDbDataParameter

The created parameter, which has already been added to the command's parameter collection.

Exceptions

ArgumentNullException

target or name is null.

ArgumentException

name is empty or white space.

See Also

AddParameter(IDbCommand, string, long)

Adds a 64-bit integer parameter (Int64) with the given name and value to the command.

public static IDbDataParameter AddParameter(this IDbCommand target, string name, long value)

Parameters

target IDbCommand

The command to add the parameter to.

name string

The name of the parameter.

value long

The value of the parameter.

Returns

IDbDataParameter

The created parameter, which has already been added to the command's parameter collection.

Exceptions

ArgumentNullException

target or name is null.

ArgumentException

name is empty or white space.

See Also

AddParameter(IDbCommand, string, short)

Adds a 16-bit integer parameter (Int16) with the given name and value to the command.

public static IDbDataParameter AddParameter(this IDbCommand target, string name, short value)

Parameters

target IDbCommand

The command to add the parameter to.

name string

The name of the parameter.

value short

The value of the parameter.

Returns

IDbDataParameter

The created parameter, which has already been added to the command's parameter collection.

Exceptions

ArgumentNullException

target or name is null.

ArgumentException

name is empty or white space.

See Also

AddParameter(IDbCommand, string, DateTime)

Adds a date and time parameter (DateTime) with the given name and value to the command.

public static IDbDataParameter AddParameter(this IDbCommand target, string name, DateTime value)

Parameters

target IDbCommand

The command to add the parameter to.

name string

The name of the parameter.

value DateTime

The value of the parameter.

Returns

IDbDataParameter

The created parameter, which has already been added to the command's parameter collection.

Exceptions

ArgumentNullException

target or name is null.

ArgumentException

name is empty or white space.

See Also

AddParameter(IDbCommand, string, double)

Adds a double-precision floating point parameter (Double) with the given name and value to the command.

public static IDbDataParameter AddParameter(this IDbCommand target, string name, double value)

Parameters

target IDbCommand

The command to add the parameter to.

name string

The name of the parameter.

value double

The value of the parameter.

Returns

IDbDataParameter

The created parameter, which has already been added to the command's parameter collection.

Exceptions

ArgumentNullException

target or name is null.

ArgumentException

name is empty or white space.

See Also

AddParameter(IDbCommand, string, decimal)

Adds a decimal parameter (Decimal) with the given name and value to the command.

public static IDbDataParameter AddParameter(this IDbCommand target, string name, decimal value)

Parameters

target IDbCommand

The command to add the parameter to.

name string

The name of the parameter.

value decimal

The value of the parameter.

Returns

IDbDataParameter

The created parameter, which has already been added to the command's parameter collection.

Exceptions

ArgumentNullException

target or name is null.

ArgumentException

name is empty or white space.

See Also

AddParameter(IDbCommand, string, Guid)

Adds a GUID parameter (Guid) with the given name and value to the command.

public static IDbDataParameter AddParameter(this IDbCommand target, string name, Guid value)

Parameters

target IDbCommand

The command to add the parameter to.

name string

The name of the parameter.

value Guid

The value of the parameter.

Returns

IDbDataParameter

The created parameter, which has already been added to the command's parameter collection.

Exceptions

ArgumentNullException

target or name is null.

ArgumentException

name is empty or white space.

See Also

AddParameter(IDbCommand, string, DateTimeOffset)

Adds a date and time with offset parameter (DateTimeOffset) with the given name and value to the command.

public static IDbDataParameter AddParameter(this IDbCommand target, string name, DateTimeOffset value)

Parameters

target IDbCommand

The command to add the parameter to.

name string

The name of the parameter.

value DateTimeOffset

The value of the parameter.

Returns

IDbDataParameter

The created parameter, which has already been added to the command's parameter collection.

Exceptions

ArgumentNullException

target or name is null.

ArgumentException

name is empty or white space.

See Also

AddParameter(IDbCommand, string, object?, DbType, ParameterDirection)

Adds a typed parameter with the given name, value, and direction to the command.

public static IDbDataParameter AddParameter(this IDbCommand target, string name, object? value, DbType type, ParameterDirection direction = ParameterDirection.Input)

Parameters

target IDbCommand

The command to add the parameter to.

name string

The name of the parameter.

value object

The value of the parameter. It is assigned as given: a null is not converted to Value, so pass Value to send a database null.

type DbType

The DbType of the parameter.

direction ParameterDirection

The direction of the parameter.

Returns

IDbDataParameter

The created parameter, which has already been added to the command's parameter collection.

Exceptions

ArgumentNullException

target or name is null.

ArgumentException

name is empty or white space.