The requested page is not available for the requested platform. You are viewing the content for .NET Framework 4.5.2+ platform.
.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.v19.2.dll

Declaration

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

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.

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.

Returns

Type Description
Object

The evaluated value.

Returns

Type Description
Object

The evaluated value.

Type Parameters

Name Description
ClassType

Type Parameters

Name Description
ClassType

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

See Also