Skip to main content
All docs
V22.2

CriteriaOperator.FromLambda<TModel>(Expression<Func<TModel, Boolean>>) 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>(
    Expression<Func<TModel, bool>> lambda
)

Parameters

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

A LINQ expression to convert.

Type Parameters

Name Description
TModel

A type of object to which the expression is applied.

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 "[Company] = 'DevExpress'"
CriteriaOperator simpleCriteria = CriteriaOperator.FromLambda<User>(u => u.Company == "DevExpress");
// Returns "[Products][].Avg([Price]) > 100.0"
CriteriaOperator complexCriteria = CriteriaOperator.FromLambda<Supplier>(supplier => supplier.Products.Average(product = > product.Price) > 100 );
// Returns "[Angle] < Acos(10)"
CriteriaOperator mathCriteria = CriteriaOperator.FromLambda<Shape>(shape  => shape.Angle < Math.Acos(10));

Tip

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

See Also