Click or drag to resize
QueryableExIfTResult Method (IQueryProvider, ExpressionFuncBoolean, IEnumerableTResult)
Returns an enumerable sequence if the evaluation result of the given condition is true, otherwise returns an empty sequence.

Namespace: System.Linq
Assembly: System.Interactive.Providers (in System.Interactive.Providers.dll) Version: 1.2.0.0
Syntax
C#
public static IQueryable<TResult> If<TResult>(
	this IQueryProvider provider,
	Expression<Func<bool>> condition,
	IEnumerable<TResult> thenSource
)

Parameters

provider
Type: System.LinqIQueryProvider
Query provider.
condition
Type: System.Linq.ExpressionsExpressionFuncBoolean
Condition to evaluate.
thenSource
Type: System.Collections.GenericIEnumerableTResult
Sequence to return in case the condition evaluates true.

Type Parameters

TResult
Result sequence element type.

Return Value

Type: IQueryableTResult
The given input sequence if the condition evaluates true; otherwise, an empty sequence.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type IQueryProvider. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).
See Also