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
targetIDbCommandThe command to add the parameter to.
namestringThe name of the parameter.
valueobjectThe 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
targetornameis null.- ArgumentException
nameis 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
targetIDbCommandThe command to add the parameter to.
namestringThe name of the parameter.
valuestringThe 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
targetornameis null.- ArgumentException
nameis 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
targetIDbCommandThe command to add the parameter to.
namestringThe name of the parameter.
valueintThe value of the parameter.
Returns
- IDbDataParameter
The created parameter, which has already been added to the command's parameter collection.
Exceptions
- ArgumentNullException
targetornameis null.- ArgumentException
nameis 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
targetIDbCommandThe command to add the parameter to.
namestringThe name of the parameter.
valuelongThe value of the parameter.
Returns
- IDbDataParameter
The created parameter, which has already been added to the command's parameter collection.
Exceptions
- ArgumentNullException
targetornameis null.- ArgumentException
nameis 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
targetIDbCommandThe command to add the parameter to.
namestringThe name of the parameter.
valueshortThe value of the parameter.
Returns
- IDbDataParameter
The created parameter, which has already been added to the command's parameter collection.
Exceptions
- ArgumentNullException
targetornameis null.- ArgumentException
nameis 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
targetIDbCommandThe command to add the parameter to.
namestringThe name of the parameter.
valueDateTimeThe value of the parameter.
Returns
- IDbDataParameter
The created parameter, which has already been added to the command's parameter collection.
Exceptions
- ArgumentNullException
targetornameis null.- ArgumentException
nameis 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
targetIDbCommandThe command to add the parameter to.
namestringThe name of the parameter.
valuedoubleThe value of the parameter.
Returns
- IDbDataParameter
The created parameter, which has already been added to the command's parameter collection.
Exceptions
- ArgumentNullException
targetornameis null.- ArgumentException
nameis 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
targetIDbCommandThe command to add the parameter to.
namestringThe name of the parameter.
valuedecimalThe value of the parameter.
Returns
- IDbDataParameter
The created parameter, which has already been added to the command's parameter collection.
Exceptions
- ArgumentNullException
targetornameis null.- ArgumentException
nameis 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
targetIDbCommandThe command to add the parameter to.
namestringThe name of the parameter.
valueGuidThe value of the parameter.
Returns
- IDbDataParameter
The created parameter, which has already been added to the command's parameter collection.
Exceptions
- ArgumentNullException
targetornameis null.- ArgumentException
nameis 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
targetIDbCommandThe command to add the parameter to.
namestringThe name of the parameter.
valueDateTimeOffsetThe value of the parameter.
Returns
- IDbDataParameter
The created parameter, which has already been added to the command's parameter collection.
Exceptions
- ArgumentNullException
targetornameis null.- ArgumentException
nameis 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
targetIDbCommandThe command to add the parameter to.
namestringThe name of the parameter.
valueobjectThe value of the parameter. It is assigned as given: a null is not converted to Value, so pass Value to send a database null.
typeDbTypeThe DbType of the parameter.
directionParameterDirectionThe direction of the parameter.
Returns
- IDbDataParameter
The created parameter, which has already been added to the command's parameter collection.
Exceptions
- ArgumentNullException
targetornameis null.- ArgumentException
nameis empty or white space.