.NET Framework 4.5.2+
.NET Framework 4.5.2+
.NET Standard 2.0+

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.v20.2.dll


public object Evaluate<ClassType>(
    CriteriaOperator expression,
    CriteriaOperator criteria
Public Function Evaluate(Of ClassType)(
    expression As CriteriaOperator,
    criteria As CriteriaOperator
) As Object


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

The type of objects against which the expression is evaluated.


Type Description

The evaluated value.


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).

See Also