Skip to main content
.NET Framework 4.6.2+

Session.Evaluate<ClassType>(CriteriaOperator, CriteriaOperator) Method

Evaluates the specified expression for objects of the type designated by the specified generic type parameter.

Namespace: DevExpress.Xpo

Assembly: DevExpress.Xpo.v24.2.dll

#Declaration

public object Evaluate<ClassType>(
    CriteriaOperator expression,
    CriteriaOperator criteria
)

#Parameters

Name Type Description
expression CriteriaOperator

A CriteriaOperator object that specifies the expression to be evaluated.

criteria CriteriaOperator

A CriteriaOperator object that specifies the filter criteria. The objects that match this criteria are used to evaluate the expression.

#Type Parameters

Name Description
ClassType

The type of objects against which the expression is evaluated.

#Returns

Type Description
Object

The evaluated value.

#Remarks

Use this method to evaluate a specific expression against specific objects. In the expression that is specified by the expression parameter you can use the functions specified by the Aggregate enumeration and you can also use a combination of these functions.

For example, you can use the Count() function to calculate the number of objects specified.

The criteria parameter specifies the criteria used for object selection. The expression is evaluated only against the objects that match these criteria. Set the criteria to null (Nothing in VB.NET) to evaluate the expression against all the objects in the data store.

To construct the expression and criteria, use the static CriteriaOperator.Parse method. The method takes a string representation of the required expression and retrieves a CriteriaOperator object that corresponds to this expression.

The following code snippet demonstrates how to calculate the sum of orders paid within the last ten days:

using DevExpress.Data.Filtering;

//...

decimal sumPaid = (decimal)session.Evaluate<Order>(CriteriaOperator.Parse("Sum(OrderTotals)"), 
    new BinaryOperator("OrderDate", DateTime.Today.AddDays(-10), BinaryOperatorType.Greater));

Note that direct type casting may fail, since the Evaluate can return null (Nothing in VB).

The following code snippets (auto-collected from DevExpress Examples) contain references to the Evaluate<ClassType>(CriteriaOperator, CriteriaOperator) method.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

See Also