Table of Contents

Class InOperator<T>

Namespace
Cuemon.Data
Assembly
Cuemon.Data.dll

Provides a safe way to include a Transact-SQL WHERE clause with an IN operator.

public abstract class InOperator<T>

Type Parameters

T
Inheritance
InOperator<T>
Derived

Constructors

InOperator(Func<string>)

Initializes a new instance of the InOperator<T> class.

protected InOperator(Func<string> parameterPrefixGenerator = null)

Parameters

parameterPrefixGenerator Func<string>

The function delegate that generates a random prefix for a parameter name.

Properties

ParameterPrefix

Gets the prefix of the parameter name that will be concatenated with index of both ArgumentsSelector(T, int) and ParametersSelector(T, int).

protected string ParameterPrefix { get; }

Property Value

string

The prefix of the parameter name that will be concatenated with index.

Methods

ArgumentsSelector(T, int)

A callback method that is responsible for the values passed to the ToSafeResult(params T[]) method.

protected virtual string ArgumentsSelector(T expression, int index)

Parameters

expression T

An expression to test for a match in the IN operator.

index int

The index of the expression.

Returns

string

A string representing the argument of the expression.

Remarks

Default is @param concatenated with ParameterPrefix and index, eg. @paramAbcdef0.

ParametersSelector(T, int)

A callback method that is responsible for the values passed to the ToSafeResult(params T[]) method.

protected abstract IDbDataParameter ParametersSelector(T expression, int index)

Parameters

expression T

An expression to test for a match in the IN operator.

index int

The index of the expression.

Returns

IDbDataParameter

An IDbDataParameter representing the value of the expression.

ToSafeResult(IEnumerable<T>, Func<IEnumerable<string>, string>)

Converts the specified sequence of expressions to a SQL injection safe InOperatorResult.

public InOperatorResult ToSafeResult(IEnumerable<T> expressions, Func<IEnumerable<string>, string> argumentsStringConverter = null)

Parameters

expressions IEnumerable<T>

The expressions to test for a match in the IN operator of the WHERE clause.

argumentsStringConverter Func<IEnumerable<string>, string>

The function delegate arguments string converter.

Returns

InOperatorResult

A new instance of InOperatorResult.

Exceptions

ArgumentNullException

expressions cannot be null.

ToSafeResult(params T[])

Converts the specified sequence of expressions to a SQL injection safe InOperatorResult.

public InOperatorResult ToSafeResult(params T[] expressions)

Parameters

expressions T[]

The expressions to test for a match in the IN operator of the WHERE clause.

Returns

InOperatorResult

A new instance of InOperatorResult.