When creating a report, I have to fulfill 3 queries that are related to individual objects of the same context. Since they are quite heavy, I decided to use .ToListAsync(); so that they run in parallel, but, to my surprise, I get an exception to this ...
What is the correct way to execute queries in parallel using EF 6? Do I have to manually start new tasks?
Change 1
Code is basically
using(var MyCtx = new MyCtx()) { var r1 = MyCtx.E1.Where(bla bla bla).ToListAsync(); var r2 = MyCtx.E2.Where(ble ble ble).ToListAsync(); var r3 = MyCtx.E3.Where(ble ble ble).ToListAsync(); Task.WhenAll(r1,r2,r3); DoSomething(r1.Result, r2.Result, r3.Result); }
source share