Skip to main content
All docs
V22.2

CriteriaOperator.FromLambda<TModel, TResult>(Expression<Func<TModel, TResult>>) Method

Converts the specified LINQ-like expression to its CriteriaOperator equivalent.

Namespace: DevExpress.Data.Filtering

Assembly: DevExpress.Data.v22.2.dll

NuGet Package: DevExpress.Data

Declaration

public static CriteriaOperator FromLambda<TModel, TResult>(
    Expression<Func<TModel, TResult>> lambda
)

Parameters

Name Type Description
lambda Expression<Func<TModel, TResult>>

A LINQ expression to convert.

Type Parameters

Name Description
TModel

A type of object to which the expression is applied.

TResult

A type of object that is returned by the converted expression.

Returns

Type Description
CriteriaOperator

A CriteriaOperator equivalent to the expression passed to the method’s parameter.

Remarks

Use the FromLambda method to create a criteria operator from a LINQ-like predicate expression:

// Returns "[Name]"
CriteriaOperator stringCriteria = CriteriaOperator.FromLambda<User,string>(u => u.Name);
// Returns "[Departments].Single()"
CriteriaOperator classCriteria = CriteriaOperator.FromLambda<User, Department>(u => u.Departments.SingleOrDefault());

Tip

For information on how to build LINQ-like expressions, refer to the following topic: LINQ-Like Criteria Syntax

See Also