Method AddParameterType
- Namespace
- Open.Database.Extensions
- Assembly
- Open.Database.Extensions.MSSqlClient.dll
AddParameterType(SqlCommand, string?, SqlDbType, ParameterDirection)
Adds a parameter of the given type and direction to the command without assigning a value.
public static SqlParameter AddParameterType(this SqlCommand target, string? name, SqlDbType type, ParameterDirection direction = ParameterDirection.Input)
Parameters
targetSqlCommandThe command to add the parameter to.
namestringThe name of the parameter. It can be null only when
directionis ReturnValue.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. Set its value afterwards if it is an input parameter.
Exceptions
- ArgumentNullException
targetis null, ornameis null anddirectionis not ReturnValue.- ArgumentException
nameis empty or white space.
AddParameterType(IDbCommand, string, SqlDbType)
Adds an input parameter of the given type to a command that must be a SqlCommand, without assigning a value.
public static SqlParameter AddParameterType(this IDbCommand target, string name, SqlDbType type)
Parameters
targetIDbCommandThe command to add the parameter to. It must be a SqlCommand.
namestringThe name of the parameter.
typeSqlDbTypeThe SqlDbType of the parameter.
Returns
- SqlParameter
The created parameter, which has already been added to the command's parameter collection.
Exceptions
- InvalidCastException
targetis not a SqlCommand.- ArgumentNullException
nameis null.- ArgumentException
nameis empty or white space.