Metodo DbRawSqlQuery<TElement>.ToDictionaryAsync<TKey> (Func<TElement, TKey>, CancellationToken)
[Questa pagina è specifica della versione 6 di Entity Framework. La versione più recente è disponibile come pacchetto NuGet per "Entity Framework". Per ulteriori informazioni su Entity Framework, vedere la pagina msdn.com/data/ef.]
Crea un oggetto Dictionary<TKey, TValue> dalla query enumerandolo in modo asincrono in base a una funzione del selettore di chiave specificata.
Spazio dei nomi: System.Data.Entity.Infrastructure
Assembly: EntityFramework (in EntityFramework.dll)
Sintassi
'Dichiarazione
<SuppressMessageAttribute("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures")> _
Public Function ToDictionaryAsync(Of TKey) ( _
keySelector As Func(Of TElement, TKey), _
cancellationToken As CancellationToken _
) As Task(Of Dictionary(Of TKey, TElement))
'Utilizzo
Dim instance As DbRawSqlQuery
Dim keySelector As Func(Of TElement, TKey)
Dim cancellationToken As CancellationToken
Dim returnValue As Task(Of Dictionary(Of TKey, TElement))
returnValue = instance.ToDictionaryAsync(keySelector, _
cancellationToken)
[SuppressMessageAttribute("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures")]
public Task<Dictionary<TKey, TElement>> ToDictionaryAsync<TKey>(
Func<TElement, TKey> keySelector,
CancellationToken cancellationToken
)
[SuppressMessageAttribute(L"Microsoft.Design", L"CA1006:DoNotNestGenericTypesInMemberSignatures")]
public:
generic<typename TKey>
Task<Dictionary<TKey, TElement>^>^ ToDictionaryAsync(
Func<TElement, TKey>^ keySelector,
CancellationToken cancellationToken
)
[<SuppressMessageAttribute("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures")>]
member ToDictionaryAsync :
keySelector:Func<'TElement, 'TKey> *
cancellationToken:CancellationToken -> Task<Dictionary<'TKey, 'TElement>>
JScript does not support generic types and methods.
Parametri di tipo
- TKey
Tipo della chiave restituita da keySelector.
Parametri
- keySelector
Tipo: System.Func<TElement, TKey>
Funzione per estrarre una chiave da ogni elemento.
- cancellationToken
Tipo: System.Threading.CancellationToken
Oggetto CancellationToken da osservare durante l'attesa del completamento dell'attività.
Valore restituito
Tipo: System.Threading.Tasks.Task<Dictionary<TKey, TElement>>
Attività che rappresenta l'operazione asincrona.Il risultato dell'attività contiene un oggetto Dictionary<TKey, TValue> che contiene le chiavi e i valori selezionati.
Note
Non è consentito eseguire più operazioni attive nella stessa istanza di contesto. Utilizzare 'await' per assicurarsi che eventuali operazioni asincrone vengano completate prima di chiamare un altro metodo su questo contesto.