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

XPQueryExtensions.ToDictionaryAsync<T, TKey, TElement>(IQueryable<T>, Func<T, TKey>, Func<T, TElement>, IEqualityComparer<TKey>, CancellationToken) Method

Asynchronously enumerates a query and uses a key selector, an element selector, and a comparer to construct a Dictionary<TKey,TValue>.

Namespace: DevExpress.Xpo

Assembly: DevExpress.Xpo.v20.2.dll


public static Task<Dictionary<TKey, TElement>> ToDictionaryAsync<T, TKey, TElement>(
    this IQueryable<T> query,
    Func<T, TKey> keySelector,
    Func<T, TElement> elementSelector,
    IEqualityComparer<TKey> equalityComparer,
    CancellationToken cancellationToken = default(CancellationToken)
Public Shared Function ToDictionaryAsync(Of T, TKey, TElement)(
    query As IQueryable(Of T),
    keySelector As Func(Of T, TKey),
    elementSelector As Func(Of T, TElement),
    equalityComparer As IEqualityComparer(Of TKey),
    cancellationToken As CancellationToken = Nothing
) As Task(Of Dictionary(Of TKey, TElement))


Name Type Description
query IQueryable<T>

An XPQuery<T> to be enumerated.

keySelector Func<T, TKey>

A function that acquires each persistent object's key.

elementSelector Func<T, TElement>

A function that returns a result value for each persistent object.

equalityComparer IEqualityComparer<TKey>

An IEqualityComparer<T> object that compares keys created for persistent objects.

Optional Parameters

Name Type Default Description
cancellationToken CancellationToken


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

Type Parameters



Type Description
Task<Dictionary<TKey, TElement>>

A Task that returns a Dictionary<TKey,TValue>.

See Also