Share via


DbRawSqlQuery<TElement>.ToDictionaryAsync<TKey> 方法 (Func<TElement, TKey>)

[此頁面專屬於 Entity Framework 第 6 版。最新版本可從 'Entity Framework' NuGet 套件取得。如需 Entity Framework 的詳細資訊,請參閱 msdn.com/data/ef。]

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

命名空間:  System.Data.Entity.Infrastructure
組件:  EntityFramework (在 EntityFramework.dll 中)

語法

'宣告
<SuppressMessageAttribute("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures")> _
Public Function ToDictionaryAsync(Of TKey) ( _
    keySelector As Func(Of TElement, TKey) _
) As Task(Of Dictionary(Of TKey, TElement))
'用途
Dim instance As DbRawSqlQuery 
Dim keySelector As Func(Of TElement, TKey)
Dim returnValue As Task(Of Dictionary(Of TKey, TElement))

returnValue = instance.ToDictionaryAsync(keySelector)
[SuppressMessageAttribute("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures")]
public Task<Dictionary<TKey, TElement>> ToDictionaryAsync<TKey>(
    Func<TElement, TKey> keySelector
)
[SuppressMessageAttribute(L"Microsoft.Design", L"CA1006:DoNotNestGenericTypesInMemberSignatures")]
public:
generic<typename TKey>
Task<Dictionary<TKey, TElement>^>^ ToDictionaryAsync(
    Func<TElement, TKey>^ keySelector
)
[<SuppressMessageAttribute("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures")>]
member ToDictionaryAsync : 
        keySelector:Func<'TElement, 'TKey> -> Task<Dictionary<'TKey, 'TElement>> 
JScript does not support generic types and methods.

類型參數

  • TKey
    由 keySelector 傳回之索引鍵的類型。

參數

  • keySelector
    類型:System.Func<TElement, TKey>
    用來從各個項目擷取索引鍵的函式。

傳回值

類型:System.Threading.Tasks.Task<Dictionary<TKey, TElement>>
表示非同步作業的工作。工作結果包含 Dictionary<TKey, TValue>,其包含選取的索引鍵和值。

備註

不支援相同內容執行個體上的多個作用中作業。 使用 'await' 確保在此內容上呼叫另一個方法之前,所有非同步作業都已完成。

請參閱

參考

DbRawSqlQuery<TElement> 類別

ToDictionaryAsync 多載

System.Data.Entity.Infrastructure 命名空間