All docs
V19.2
19.2
19.1
The page you are viewing does not exist in version 19.1. This link will take you to the root page.
18.2
The page you are viewing does not exist in version 18.2. This link will take you to the root page.
18.1
The page you are viewing does not exist in version 18.1. This link will take you to the root page.
17.2
The page you are viewing does not exist in version 17.2. This link will take you to the root page.
.NET Framework 4.5.2+
.NET Framework 4.5.2+
.NET Standard 2.0+
.NET Core 3.0+

XPObjectSpace.EvaluateAsync(Type, CriteriaOperator, CriteriaOperator, CancellationToken) Method

Asynchronously evaluates the specified criteria for business objects of the given type.

Namespace: DevExpress.ExpressApp.Xpo

Assembly: DevExpress.ExpressApp.Xpo.v19.2.dll

Declaration

public Task<object> EvaluateAsync(
    Type objectType,
    CriteriaOperator expression,
    CriteriaOperator criteria,
    CancellationToken cancellationToken = null
)
Public Function EvaluateAsync(
    objectType As Type,
    expression As CriteriaOperator,
    criteria As CriteriaOperator,
    cancellationToken As CancellationToken = Nothing
) As Task(Of Object)
public Task<object> EvaluateAsync(
    Type objectType,
    CriteriaOperator expression,
    CriteriaOperator criteria,
    CancellationToken cancellationToken = default(CancellationToken)
)
Public Function EvaluateAsync(
    objectType As Type,
    expression As CriteriaOperator,
    criteria As CriteriaOperator,
    cancellationToken As CancellationToken = Nothing
) As Task(Of Object)
public Task<object> EvaluateAsync(
    Type objectType,
    CriteriaOperator expression,
    CriteriaOperator criteria,
    CancellationToken cancellationToken = default(CancellationToken)
)
Public Function EvaluateAsync(
    objectType As Type,
    expression As CriteriaOperator,
    criteria As CriteriaOperator,
    cancellationToken As CancellationToken = Nothing
) As Task(Of Object)

Parameters

Name Type Description
objectType Type

A Type 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.

cancellationToken CancellationToken

A CancellationToken object that delivers a cancellation notice to the running operation.

Parameters

Name Type Description
objectType Type

A Type 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.

cancellationToken CancellationToken

A CancellationToken object that delivers a cancellation notice to the running operation.

Parameters

Name Type Description
objectType Type

A Type 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.

cancellationToken CancellationToken

A CancellationToken object that delivers a cancellation notice to the running operation.

Returns

Type Description
Task<Object>

A Task that returns an object. This object represents the evaluated value. null (Nothing in Visual Basic) if no persistent object is found that matches the criteria.

Returns

Type Description
Task<Object>

A Task that returns an object. This object represents the evaluated value. null (Nothing in Visual Basic) if no persistent object is found that matches the criteria.

Returns

Type Description
Task<Object>

A Task that returns an object. This object represents the evaluated value. null (Nothing in Visual Basic) if no persistent object is found that matches the criteria.

Remarks

You can use the static CriteriaOperator.Parse method to construct the expression and criteria. This method takes a string representation of the required expression and creates the CriteriaOperator object that corresponds to this expression.

The following code demonstrates how to use this method in a View Controller to evaluate contact's assigned tasks.

using DevExpress.Data.Filtering;
using DevExpress.ExpressApp;
using DevExpress.ExpressApp.Actions;
using DevExpress.ExpressApp.Xpo;
using System;
using System.Threading;
// ...
public class AsyncTasksCountController : ObjectViewController<DetailView, Contact> {
    public AsyncTasksCountController() : base() {
        SimpleAction EvaluateTasksCountAction = new SimpleAction(this, "Assigned tasks count", "Edit");
        EvaluateTasksCountAction.SelectionDependencyType = SelectionDependencyType.RequireSingleObject;
        EvaluateTasksCountAction.Execute += EvaluateTasksCountAction_Execute;
    }
    async private void EvaluateTasksCountAction_Execute(object sender, SimpleActionExecuteEventArgs e) {
        CancellationTokenSource cancellationTokenSource = new CancellationTokenSource();
        Guid currentContactOid = ViewCurrentObject.Oid;
        XPObjectSpace taskObjectSpace = (XPObjectSpace)Application.CreateObjectSpace(typeof(DemoTask));
        object tasksCount =
            await taskObjectSpace.EvaluateAsync(
            typeof(DemoTask), CriteriaOperator.Parse("Count()"),
            CriteriaOperator.Parse(string.Format("[AssignedTo.Oid] = '{0}'", currentContactOid)),
            cancellationTokenSource.Token);
        if (tasksCount != null) {
            ViewCurrentObject.AssignedTasksCount = (int)tasksCount;
        }
    }
}

In the current example, the cancellationToken parameter is used for demonstration purposes. You can skip it or use to cancel an asynchronous operation as shown in the CancellationToken topic.

See Also