EntityFrameworkQueryableExtensions.ToDictionaryAsync 方法

定義

多載

ToDictionaryAsync<TSource,TKey,TElement>(IQueryable<TSource>, Func<TSource,TKey>, Func<TSource,TElement>, CancellationToken)

Dictionary<TKey,TValue>根據指定的索引鍵選取器和元素選取器函式,以非同步方式列舉,從 IQueryable<T> 建立 。

ToDictionaryAsync<TSource,TKey,TElement>(IQueryable<TSource>, Func<TSource,TKey>, Func<TSource,TElement>, IEqualityComparer<TKey>, CancellationToken)

Dictionary<TKey,TValue>根據指定的索引鍵選取器函式、比較子和元素選取器函式,以非同步方式列舉,從 IQueryable<T> 建立 。

ToDictionaryAsync<TSource,TKey>(IQueryable<TSource>, Func<TSource,TKey>, CancellationToken)

Dictionary<TKey,TValue>根據指定的索引鍵選取器函式以非同步方式列舉,從 IQueryable<T> 建立 。

ToDictionaryAsync<TSource,TKey>(IQueryable<TSource>, Func<TSource,TKey>, IEqualityComparer<TKey>, CancellationToken)

Dictionary<TKey,TValue>根據指定的索引鍵選取器函式和比較子,以非同步方式列舉,從 IQueryable<T> 建立 。

ToDictionaryAsync<TSource,TKey,TElement>(IQueryable<TSource>, Func<TSource,TKey>, Func<TSource,TElement>, CancellationToken)

Dictionary<TKey,TValue>根據指定的索引鍵選取器和元素選取器函式,以非同步方式列舉,從 IQueryable<T> 建立 。

public static System.Threading.Tasks.Task<System.Collections.Generic.Dictionary<TKey,TElement>> ToDictionaryAsync<TSource,TKey,TElement> (this System.Linq.IQueryable<TSource> source, Func<TSource,TKey> keySelector, Func<TSource,TElement> elementSelector, System.Threading.CancellationToken cancellationToken = default);
static member ToDictionaryAsync : System.Linq.IQueryable<'Source> * Func<'Source, 'Key> * Func<'Source, 'Element> * System.Threading.CancellationToken -> System.Threading.Tasks.Task<System.Collections.Generic.Dictionary<'Key, 'Element>>
<Extension()>
Public Function ToDictionaryAsync(Of TSource, TKey, TElement) (source As IQueryable(Of TSource), keySelector As Func(Of TSource, TKey), elementSelector As Func(Of TSource, TElement), Optional cancellationToken As CancellationToken = Nothing) As Task(Of Dictionary(Of TKey, TElement))

類型參數

TSource

source 項目的類型。

TKey

keySelector 所傳回之索引鍵的型別。

TElement

elementSelector 所傳回值的型別。

參數

source
IQueryable<TSource>

用來建立 Dictionary<TKey,TValue> 的來源 IQueryable<T>

keySelector
Func<TSource,TKey>

用來從各個項目擷取索引鍵的函式。

elementSelector
Func<TSource,TElement>

用來從每個項目產生結果項目值的轉換函式。

cancellationToken
CancellationToken

等候 CancellationToken 工作完成時要觀察的 。

傳回

Task<Dictionary<TKey,TElement>>

代表非同步作業的工作。 工作結果包含 , Dictionary<TKey,TValue> 其中包含從輸入序列選取的類型 TElement 值。

例外狀況

sourcekeySelectorelementSelectornull

備註

不支援相同內容實例上的多個作用中作業。 使用 await 以確保任何非同步作業都已完成,再在此內容上呼叫另一個方法。 如需詳細資訊和範例,請參閱 避免 DbCoNtext 執行緒問題

如需詳細資訊和範例 ,請參閱使用 EF Core 查詢資料

適用於

ToDictionaryAsync<TSource,TKey,TElement>(IQueryable<TSource>, Func<TSource,TKey>, Func<TSource,TElement>, IEqualityComparer<TKey>, CancellationToken)

Dictionary<TKey,TValue>根據指定的索引鍵選取器函式、比較子和元素選取器函式,以非同步方式列舉,從 IQueryable<T> 建立 。

public static System.Threading.Tasks.Task<System.Collections.Generic.Dictionary<TKey,TElement>> ToDictionaryAsync<TSource,TKey,TElement> (this System.Linq.IQueryable<TSource> source, Func<TSource,TKey> keySelector, Func<TSource,TElement> elementSelector, System.Collections.Generic.IEqualityComparer<TKey> comparer, System.Threading.CancellationToken cancellationToken = default);
public static System.Threading.Tasks.Task<System.Collections.Generic.Dictionary<TKey,TElement>> ToDictionaryAsync<TSource,TKey,TElement> (this System.Linq.IQueryable<TSource> source, Func<TSource,TKey> keySelector, Func<TSource,TElement> elementSelector, System.Collections.Generic.IEqualityComparer<TKey>? comparer, System.Threading.CancellationToken cancellationToken = default);
static member ToDictionaryAsync : System.Linq.IQueryable<'Source> * Func<'Source, 'Key> * Func<'Source, 'Element> * System.Collections.Generic.IEqualityComparer<'Key> * System.Threading.CancellationToken -> System.Threading.Tasks.Task<System.Collections.Generic.Dictionary<'Key, 'Element>>
<Extension()>
Public Function ToDictionaryAsync(Of TSource, TKey, TElement) (source As IQueryable(Of TSource), keySelector As Func(Of TSource, TKey), elementSelector As Func(Of TSource, TElement), comparer As IEqualityComparer(Of TKey), Optional cancellationToken As CancellationToken = Nothing) As Task(Of Dictionary(Of TKey, TElement))

類型參數

TSource

source 項目的類型。

TKey

keySelector 所傳回之索引鍵的型別。

TElement

elementSelector 所傳回值的型別。

參數

source
IQueryable<TSource>

用來建立 Dictionary<TKey,TValue> 的來源 IQueryable<T>

keySelector
Func<TSource,TKey>

用來從各個項目擷取索引鍵的函式。

elementSelector
Func<TSource,TElement>

用來從每個項目產生結果項目值的轉換函式。

comparer
IEqualityComparer<TKey>

用來比較金鑰的 IEqualityComparer<T>

cancellationToken
CancellationToken

等候 CancellationToken 工作完成時要觀察的 。

傳回

Task<Dictionary<TKey,TElement>>

代表非同步作業的工作。 工作結果包含 , Dictionary<TKey,TValue> 其中包含從輸入序列選取的類型 TElement 值。

例外狀況

sourcekeySelectorelementSelectornull

備註

不支援相同內容實例上的多個作用中作業。 使用 await 以確保任何非同步作業都已完成,再在此內容上呼叫另一個方法。 如需詳細資訊和範例,請參閱 避免 DbCoNtext 執行緒問題

如需詳細資訊和範例 ,請參閱使用 EF Core 查詢資料

適用於

ToDictionaryAsync<TSource,TKey>(IQueryable<TSource>, Func<TSource,TKey>, CancellationToken)

Dictionary<TKey,TValue>根據指定的索引鍵選取器函式以非同步方式列舉,從 IQueryable<T> 建立 。

public static System.Threading.Tasks.Task<System.Collections.Generic.Dictionary<TKey,TSource>> ToDictionaryAsync<TSource,TKey> (this System.Linq.IQueryable<TSource> source, Func<TSource,TKey> keySelector, System.Threading.CancellationToken cancellationToken = default);
static member ToDictionaryAsync : System.Linq.IQueryable<'Source> * Func<'Source, 'Key> * System.Threading.CancellationToken -> System.Threading.Tasks.Task<System.Collections.Generic.Dictionary<'Key, 'Source>>
<Extension()>
Public Function ToDictionaryAsync(Of TSource, TKey) (source As IQueryable(Of TSource), keySelector As Func(Of TSource, TKey), Optional cancellationToken As CancellationToken = Nothing) As Task(Of Dictionary(Of TKey, TSource))

類型參數

TSource

source 項目的類型。

TKey

keySelector 所傳回之索引鍵的型別。

參數

source
IQueryable<TSource>

用來建立 Dictionary<TKey,TValue> 的來源 IQueryable<T>

keySelector
Func<TSource,TKey>

用來從各個項目擷取索引鍵的函式。

cancellationToken
CancellationToken

等候 CancellationToken 工作完成時要觀察的 。

傳回

Task<Dictionary<TKey,TSource>>

代表非同步作業的工作。 工作結果包含 Dictionary<TKey,TValue> ,其中包含選取的索引鍵和值。

例外狀況

sourcekeySelectornull

備註

不支援相同內容實例上的多個作用中作業。 使用 await 以確保任何非同步作業都已完成,再在此內容上呼叫另一個方法。 如需詳細資訊和範例,請參閱 避免 DbCoNtext 執行緒問題

如需詳細資訊和範例 ,請參閱使用 EF Core 查詢資料

適用於

ToDictionaryAsync<TSource,TKey>(IQueryable<TSource>, Func<TSource,TKey>, IEqualityComparer<TKey>, CancellationToken)

Dictionary<TKey,TValue>根據指定的索引鍵選取器函式和比較子,以非同步方式列舉,從 IQueryable<T> 建立 。

public static System.Threading.Tasks.Task<System.Collections.Generic.Dictionary<TKey,TSource>> ToDictionaryAsync<TSource,TKey> (this System.Linq.IQueryable<TSource> source, Func<TSource,TKey> keySelector, System.Collections.Generic.IEqualityComparer<TKey> comparer, System.Threading.CancellationToken cancellationToken = default);
static member ToDictionaryAsync : System.Linq.IQueryable<'Source> * Func<'Source, 'Key> * System.Collections.Generic.IEqualityComparer<'Key> * System.Threading.CancellationToken -> System.Threading.Tasks.Task<System.Collections.Generic.Dictionary<'Key, 'Source>>
<Extension()>
Public Function ToDictionaryAsync(Of TSource, TKey) (source As IQueryable(Of TSource), keySelector As Func(Of TSource, TKey), comparer As IEqualityComparer(Of TKey), Optional cancellationToken As CancellationToken = Nothing) As Task(Of Dictionary(Of TKey, TSource))

類型參數

TSource

source 項目的類型。

TKey

keySelector 所傳回之索引鍵的型別。

參數

source
IQueryable<TSource>

用來建立 Dictionary<TKey,TValue> 的來源 IQueryable<T>

keySelector
Func<TSource,TKey>

用來從各個項目擷取索引鍵的函式。

comparer
IEqualityComparer<TKey>

用來比較金鑰的 IEqualityComparer<T>

cancellationToken
CancellationToken

等候 CancellationToken 工作完成時要觀察的 。

傳回

Task<Dictionary<TKey,TSource>>

代表非同步作業的工作。 工作結果包含 Dictionary<TKey,TValue> ,其中包含選取的索引鍵和值。

例外狀況

sourcekeySelectornull

備註

不支援相同內容實例上的多個作用中作業。 使用 await 以確保任何非同步作業都已完成,再在此內容上呼叫另一個方法。 如需詳細資訊和範例,請參閱 避免 DbCoNtext 執行緒問題

如需詳細資訊和範例 ,請參閱使用 EF Core 查詢資料

適用於