Method AddParamIf
- Namespace
- Open.Database.Extensions
- Assembly
- Open.Database.Extensions.MSSqlClient.dll
AddParamIf(bool, string, DbType, ParameterDirection)
Conditionally adds a parameter of a DbType with no value.
public ExpressiveSqlCommand AddParamIf(bool condition, string name, DbType type, ParameterDirection direction)
Parameters
conditionboolnamestringThe name of the parameter.
typeDbTypeThe database type of the parameter.
directionParameterDirectionThe direction of the parameter. An input or input-output parameter with no value is sent as a NULL of that type.
Returns
- ExpressiveSqlCommand
This instance for use in method chaining.
Remarks
A constant 0 with a direction (AddParam("@n", 0, ParameterDirection.InputOutput)) binds to this overload as a DbType: write (object)0 or use a variable.
Exceptions
- ArgumentNullException
The parameter is added and
nameis null.- ArgumentException
The parameter is added and
nameis empty or white space, or SQL Server has no type fortype.