Method AddParameter
- Namespace
- Open.Database.Extensions
- Assembly
- Open.Database.Extensions.MSSqlClient.dll
AddParameter(SqlCommand, string, object?, SqlDbType, ParameterDirection)
Adds a typed parameter with the given name, value, and direction to the command.
public static SqlParameter AddParameter(this SqlCommand target, string name, object? value, SqlDbType type, ParameterDirection direction = ParameterDirection.Input)
Parameters
targetSqlCommandThe 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.
typeSqlDbTypeThe SqlDbType of the parameter.
directionParameterDirectionThe direction of the parameter.
Returns
- SqlParameter
The created parameter, which has already been added to the command's parameter collection.
Exceptions
- ArgumentNullException
targetornameis null.- ArgumentException
nameis empty or white space.