Back to Devexpress

XPQueryExtensions.EnumerateAsync<T>(IQueryable<T>, XPQueryExtensions.AsyncEnumerateCallback<T>) Method

xpo-devexpress-dot-xpo-dot-xpqueryextensions-dot-enumerateasync-1-x28-system-dot-linq-dot-iqueryable-0-devexpress-dot-xpo-dot-xpqueryextensions-dot-asyncenumeratecallback-0-x29.md

latest3.0 KB
Original Source

XPQueryExtensions.EnumerateAsync<T>(IQueryable<T>, XPQueryExtensions.AsyncEnumerateCallback<T>) Method

Asynchronously enumerates a specified query and notifies upon completion.

Namespace : DevExpress.Xpo

Assembly : DevExpress.Xpo.v25.2.dll

NuGet Package : DevExpress.Xpo

Declaration

csharp
public static void EnumerateAsync<T>(
    this IQueryable<T> query,
    XPQueryExtensions.AsyncEnumerateCallback<T> callback
)
vb
<ExtensionAttribute>
Public Shared Sub EnumerateAsync(Of T)(
    query As IQueryable(Of T),
    callback As XPQueryExtensions.AsyncEnumerateCallback(Of T)
)

Parameters

NameTypeDescription
queryIQueryable<T>

An XPQuery<T> to be enumerated.

| | callback | DevExpress.Xpo.XPQueryExtensions.AsyncEnumerateCallback<T> |

An AsyncEnumerateCallback<T> delegate, which is a method to be called after all elements in the query are enumerated.

|

Type Parameters

Name
T

Remarks

Example:

csharp
using System.Linq;
using DevExpress.Xpo;
using System.Collections.Generic;

// ...

var data = from c in session1.Query<Person>()
           where c.LastName.StartsWith("A")
           select c;

// Asynchronously loads XPQuery and enumerates it
data.EnumerateAsync<Contact>(delegate(IEnumerable<Contact> objects, Exception ex)
{
    // Process loaded objects here
});
vb
'NOTE: This code snippet uses implicit typing. 
'You will need to set 'Option Infer On' in the VB file or set 'Option Infer' at the project level:

Imports System.Linq
Imports DevExpress.Xpo
Imports System.Collections.Generic

' ...

Private data = from c in session1.Query(Of Person)() where c.LastName.StartsWith("A") select c

' Asynchronously loads XPQuery and enumerates it
data.EnumerateAsync(Of Contact)(Function(objects, ex) AnonymousMethod1(objects, ex))

Private Function AnonymousMethod1(ByVal objects As IEnumerable(Of Contact), _
ByVal ex As Exception) As Boolean
    ' Process loaded objects here
    Return True
End Function

See Also

GetObjectsAsync

GetObjectsInTransactionAsync

XPQueryExtensions Class

XPQueryExtensions Members

DevExpress.Xpo Namespace