Table of Contents

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

target SqlCommand

The command to add the parameter to.

name string

The name of the parameter. It can be null only when direction is ReturnValue.

type SqlDbType

The SqlDbType of the parameter.

direction ParameterDirection

The 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

target is null, or name is null and direction is not ReturnValue.

ArgumentException

name is empty or white space.