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, Int32) and ParametersSelector(T, Int32).

protected string ParameterPrefix { get; }

Property Value

String

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

Methods

ArgumentsSelector(T, Int32)

A callback method that is responsible for the values passed to the ToSafeResult(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 Int32

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, Int32)

A callback method that is responsible for the values passed to the ToSafeResult(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 Int32

The index of the expression.

Returns

IDbDataParameter

An IDbDataParameter representing the value of the expression.

ToSafeResult(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.

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.