Skip to main content
A newer version of this page is available. .
.NET Framework 4.5.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.v19.1.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 will be used to evaluate the expression.

Type Parameters

Name
ClassType

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 functions specified by the Aggregate enumeration or a combination of these functions. For example, by using the “Count()” function it’s possible to calculate the number of specified objects. The criteria parameter specifies the criteria for object selection. The expression will be evaluated only against the objects that match these criteria. Set the criteria to null to evaluate the expression against all the objects in the data store.

To construct the expression and criteria, use the static CriteriaOperator.Parse method, which takes a string representation of the required expression and retrieves the 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