次の方法で共有


QueryableExtensions.ToDictionaryAsync<TSource, TKey, TElement> メソッド (IQueryable<TSource>, Func<TSource, TKey>, Func<TSource, TElement>)

[このページは、Entity Framework 6 に関するページです。最新バージョンは、'Entity Framework' NuGet パッケージとして入手できます。Entity Framework の詳細については、msdn.com/data/ef を参照してください。]

指定されたキー セレクター関数および要素セレクター関数に従って、非同期に列挙して IQueryable<T> から Dictionary<TKey, TValue> を作成します。

名前空間:  System.Data.Entity
アセンブリ:  EntityFramework (EntityFramework.dll 内)

構文

'宣言
<SuppressMessageAttribute("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures")> _
<ExtensionAttribute> _
Public Shared Function ToDictionaryAsync(Of TSource, TKey, TElement) ( _
    source As IQueryable(Of TSource), _
    keySelector As Func(Of TSource, TKey), _
    elementSelector As Func(Of TSource, TElement) _
) As Task(Of Dictionary(Of TKey, TElement))
'使用
Dim source As IQueryable(Of TSource)
Dim keySelector As Func(Of TSource, TKey)
Dim elementSelector As Func(Of TSource, TElement)
Dim returnValue As Task(Of Dictionary(Of TKey, TElement))

returnValue = source.ToDictionaryAsync(keySelector, _
    elementSelector)
[SuppressMessageAttribute("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures")]
public static Task<Dictionary<TKey, TElement>> ToDictionaryAsync<TSource, TKey, TElement>(
    this IQueryable<TSource> source,
    Func<TSource, TKey> keySelector,
    Func<TSource, TElement> elementSelector
)
[SuppressMessageAttribute(L"Microsoft.Design", L"CA1006:DoNotNestGenericTypesInMemberSignatures")]
[ExtensionAttribute]
public:
generic<typename TSource, typename TKey, typename TElement>
static Task<Dictionary<TKey, TElement>^>^ ToDictionaryAsync(
    IQueryable<TSource>^ source, 
    Func<TSource, TKey>^ keySelector, 
    Func<TSource, TElement>^ elementSelector
)
[<SuppressMessageAttribute("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures")>]
static member ToDictionaryAsync : 
        source:IQueryable<'TSource> * 
        keySelector:Func<'TSource, 'TKey> * 
        elementSelector:Func<'TSource, 'TElement> -> Task<Dictionary<'TKey, 'TElement>> 
JScript does not support generic types and methods.

型パラメーター

  • TSource
    source の要素の型。
  • TKey
    keySelector によって返されるキーの型。
  • TElement
    elementSelector によって返される値の型。

パラメーター

  • keySelector
    型 : System.Func<TSource, TKey>
    各要素からキーを抽出する関数。
  • elementSelector
    型 : System.Func<TSource, TElement>
    各要素から結果の要素値を生成する変換関数。

戻り値

型 : System.Threading.Tasks.Task<Dictionary<TKey, TElement>>
非同期操作を表すタスク。タスクの結果には、入力シーケンスから選択された Dictionary<TKey, TValue> 型の値を格納する TElement が示されます。

使用上の注意

Visual Basic および Visual C# では、このメソッドを、IQueryable<TSource> 型のオブジェクトのインスタンス メソッドとして呼び出すことができます。インスタンス メソッド構文を使用してこのメソッドを呼び出す場合は、最初のパラメーターを省略します。詳細については、「https://msdn.microsoft.com/ja-jp/library/bb384936(v=vs.113)」または「https://msdn.microsoft.com/ja-jp/library/bb383977(v=vs.113)」を参照してください。

解説

同じコンテキスト インスタンスに対する複数のアクティブ操作はサポートされません。 このコンテキストで別のメソッドを呼び出す前に、非同期操作が完了したことを確認するために await を使用します。

参照

参照

QueryableExtensions クラス

ToDictionaryAsync オーバーロード

System.Data.Entity 名前空間