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

Session.Evaluate(XPClassInfo, CriteriaOperator, CriteriaOperator) Method

Evaluates the specified expression for objects of the specified type.

Namespace: DevExpress.Xpo

Assembly: DevExpress.Xpo.v21.2.dll


public object Evaluate(
    XPClassInfo classInfo,
    CriteriaOperator expression,
    CriteriaOperator criteria


Name Type Description
classInfo XPClassInfo

An XPClassInfo object that identifies the type of objects against which the expression is evaluated.

expression CriteriaOperator

A CriteriaOperator object that specifies the expression to evaluate.

criteria CriteriaOperator

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


Type Description

The value evaluated.


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 example demonstrates how to:

  • calculate the number of Person objects that have their IsMale property set to true,
  • calculate the number of all Person objects.

In this example, the Person class is a custom XPObject that has a Boolean IsMale property. It is assumed that this object belongs to a Session object (session1).

To calculate the number of Person objects in storage, the Session.Evaluate method is used. Its expression parameter specifies the Count function to evaluate, while the criteria parameter specifies a criteria that selects only men. The expression and criteria parameters are constructed using the CriteriaOperator.Parse method.

using DevExpress.Xpo;
using DevExpress.Data.Filtering;

class Person : XPObject {
    bool isMale;
    public bool IsMale {
        get { return isMale; }
        set { isMale = value; }

// Calculate the number of male persons without loading data items from the data base server.
object count = session1.Evaluate(typeof(Person), CriteriaOperator.Parse("Count()"),
    CriteriaOperator.Parse("IsMale = true"));

// Calculate the number of all persons without loading all data items from the data base server.
object countAll = session1.Evaluate(typeof(Person), CriteriaOperator.Parse("Count()"),
See Also