I am trying to fill in the Dictionary<long, Data>
. Method GetData
which returns data is async so I use following code to get the dictionary:
var myDictionary = entities
.GroupBy(e => e.EntityId)
.Select(e => e.First())
.ToDictionary(e => e.EntityId, async entity => await GetData(entity));
Unfortunately myDictionary is of type Dictionary<long, Task<Data>>
How to fill in the using async lambda in ToDictionary?