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(XPClassInfo, CriteriaOperator, CriteriaOperator) Method

Evaluates the specified expression for objects of the specified type.

Namespace: DevExpress.Xpo

Assembly: DevExpress.Xpo.v19.2.dll

Declaration

public object Evaluate(
    XPClassInfo classInfo,
    CriteriaOperator expression,
    CriteriaOperator criteria
)
Public Function Evaluate(
    classInfo As XPClassInfo,
    expression As CriteriaOperator,
    criteria As CriteriaOperator
) As Object
public object Evaluate(
    XPClassInfo classInfo,
    CriteriaOperator expression,
    CriteriaOperator criteria
)
Public Function Evaluate(
    classInfo As XPClassInfo,
    expression As CriteriaOperator,
    criteria As CriteriaOperator
) As Object

Parameters

Name Type Description
classInfo XPClassInfo

An XPClassInfo object that identifies the type of objects against which the expression will be 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 will be used to evaluate the expression.

Parameters

Name Type Description
classInfo XPClassInfo

An XPClassInfo object that identifies the type of objects against which the expression will be 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 will be used to evaluate the expression.

Returns

Type Description
Object

The value evaluated.

Returns

Type Description
Object

The value evaluated.

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 instance, by using the "Count()" function it's possible to calculate the number of objects specified. The criteria parameter specifies the criteria used 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 the static CriteriaOperator.Parse method can be used which takes a string representation of the required expression and retrieves a CriteriaOperator object that corresponds to this expression.

Examples

The following example demonstrates how to calculate the number of Person objects that have their IsMale property set to true.

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.
object count = session1.Evaluate(typeof(Person), CriteriaOperator.Parse("Count()"),
    CriteriaOperator.Parse("IsMale = true"))
See Also