AsyncEnumerable<TResult>.ToDictionaryAsync Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Overloads
ToDictionaryAsync<TKey,TElement>(Func<TResult,TKey>, Func<TResult,TElement>, CancellationToken)
- Source:
- AsyncEnumerable.cs
- Source:
- AsyncEnumerable.cs
Creates a Dictionary<TKey,TValue> from this AsyncEnumerable<TResult> by enumerating it asynchronously according to a specified key selector and an element selector function.
public System.Threading.Tasks.Task<System.Collections.Generic.Dictionary<TKey,TElement>> ToDictionaryAsync<TKey,TElement> (Func<TResult,TKey> keySelector, Func<TResult,TElement> elementSelector, System.Threading.CancellationToken cancellationToken = default);
member this.ToDictionaryAsync : Func<'Result, 'Key> * Func<'Result, 'Element> * System.Threading.CancellationToken -> System.Threading.Tasks.Task<System.Collections.Generic.Dictionary<'Key, 'Element>>
Public Function ToDictionaryAsync(Of TKey, TElement) (keySelector As Func(Of TResult, TKey), elementSelector As Func(Of TResult, TElement), Optional cancellationToken As CancellationToken = Nothing) As Task(Of Dictionary(Of TKey, TElement))
Type Parameters
- TKey
The type of the key returned by keySelector
.
- TElement
The type of the value returned by elementSelector
.
Parameters
- keySelector
- Func<TResult,TKey>
A function to extract a key from each element.
- elementSelector
- Func<TResult,TElement>
A transform function to produce a result element value from each element.
- cancellationToken
- CancellationToken
A CancellationToken to observe while waiting for the task to complete.
Returns
A task that represents the asynchronous operation.
The task result contains a Dictionary<TKey,TValue> that contains values of type
TElement
selected from the input sequence.
Remarks
Multiple active operations on the same context instance are not supported. Use 'await' to ensure that any asynchronous operations have completed before calling another method on this context.
Applies to
ToDictionaryAsync<TKey,TElement>(Func<TResult,TKey>, Func<TResult,TElement>, IEqualityComparer<TKey>, CancellationToken)
- Source:
- AsyncEnumerable.cs
- Source:
- AsyncEnumerable.cs
Creates a Dictionary<TKey,TValue> from this AsyncEnumerable<TResult> by enumerating it asynchronously according to a specified key selector function, a comparer, and an element selector function.
public System.Threading.Tasks.Task<System.Collections.Generic.Dictionary<TKey,TElement>> ToDictionaryAsync<TKey,TElement> (Func<TResult,TKey> keySelector, Func<TResult,TElement> elementSelector, System.Collections.Generic.IEqualityComparer<TKey> comparer, System.Threading.CancellationToken cancellationToken = default);
member this.ToDictionaryAsync : Func<'Result, 'Key> * Func<'Result, 'Element> * System.Collections.Generic.IEqualityComparer<'Key> * System.Threading.CancellationToken -> System.Threading.Tasks.Task<System.Collections.Generic.Dictionary<'Key, 'Element>>
Public Function ToDictionaryAsync(Of TKey, TElement) (keySelector As Func(Of TResult, TKey), elementSelector As Func(Of TResult, TElement), comparer As IEqualityComparer(Of TKey), Optional cancellationToken As CancellationToken = Nothing) As Task(Of Dictionary(Of TKey, TElement))
Type Parameters
- TKey
The type of the key returned by keySelector
.
- TElement
The type of the value returned by elementSelector
.
Parameters
- keySelector
- Func<TResult,TKey>
A function to extract a key from each element.
- elementSelector
- Func<TResult,TElement>
A transform function to produce a result element value from each element.
- comparer
- IEqualityComparer<TKey>
An IEqualityComparer<T> to compare keys.
- cancellationToken
- CancellationToken
A CancellationToken to observe while waiting for the task to complete.
Returns
A task that represents the asynchronous operation.
The task result contains a Dictionary<TKey,TValue> that contains values of type
TElement
selected from the input sequence.
Remarks
Multiple active operations on the same context instance are not supported. Use 'await' to ensure that any asynchronous operations have completed before calling another method on this context.
Applies to
ToDictionaryAsync<TKey>(Func<TResult,TKey>, CancellationToken)
- Source:
- AsyncEnumerable.cs
- Source:
- AsyncEnumerable.cs
Creates a Dictionary<TKey,TValue> from this AsyncEnumerable<TResult> by enumerating it asynchronously according to a specified key selector function.
public System.Threading.Tasks.Task<System.Collections.Generic.Dictionary<TKey,TResult>> ToDictionaryAsync<TKey> (Func<TResult,TKey> keySelector, System.Threading.CancellationToken cancellationToken = default);
member this.ToDictionaryAsync : Func<'Result, 'Key> * System.Threading.CancellationToken -> System.Threading.Tasks.Task<System.Collections.Generic.Dictionary<'Key, 'Result>>
Public Function ToDictionaryAsync(Of TKey) (keySelector As Func(Of TResult, TKey), Optional cancellationToken As CancellationToken = Nothing) As Task(Of Dictionary(Of TKey, TResult))
Type Parameters
- TKey
The type of the key returned by keySelector
.
Parameters
- keySelector
- Func<TResult,TKey>
A function to extract a key from each element.
- cancellationToken
- CancellationToken
A CancellationToken to observe while waiting for the task to complete.
Returns
A task that represents the asynchronous operation. The task result contains a Dictionary<TKey,TValue> that contains selected keys and values.
Remarks
Multiple active operations on the same context instance are not supported. Use 'await' to ensure that any asynchronous operations have completed before calling another method on this context.
Applies to
ToDictionaryAsync<TKey>(Func<TResult,TKey>, IEqualityComparer<TKey>, CancellationToken)
- Source:
- AsyncEnumerable.cs
- Source:
- AsyncEnumerable.cs
Creates a Dictionary<TKey,TValue> from this AsyncEnumerable<TResult> by enumerating it asynchronously according to a specified key selector function and a comparer.
public System.Threading.Tasks.Task<System.Collections.Generic.Dictionary<TKey,TResult>> ToDictionaryAsync<TKey> (Func<TResult,TKey> keySelector, System.Collections.Generic.IEqualityComparer<TKey> comparer, System.Threading.CancellationToken cancellationToken = default);
member this.ToDictionaryAsync : Func<'Result, 'Key> * System.Collections.Generic.IEqualityComparer<'Key> * System.Threading.CancellationToken -> System.Threading.Tasks.Task<System.Collections.Generic.Dictionary<'Key, 'Result>>
Public Function ToDictionaryAsync(Of TKey) (keySelector As Func(Of TResult, TKey), comparer As IEqualityComparer(Of TKey), Optional cancellationToken As CancellationToken = Nothing) As Task(Of Dictionary(Of TKey, TResult))
Type Parameters
- TKey
The type of the key returned by keySelector
.
Parameters
- keySelector
- Func<TResult,TKey>
A function to extract a key from each element.
- comparer
- IEqualityComparer<TKey>
An IEqualityComparer<T> to compare keys.
- cancellationToken
- CancellationToken
A CancellationToken to observe while waiting for the task to complete.
Returns
A task that represents the asynchronous operation. The task result contains a Dictionary<TKey,TValue> that contains selected keys and values.
Remarks
Multiple active operations on the same context instance are not supported. Use 'await' to ensure that any asynchronous operations have completed before calling another method on this context.
Applies to
Entity Framework