Task.WhenAll
var parallelSupplierTask = dbParallel1.Supplier.Where(x => x.Name.Contains("7")).OrderByDescending(x => x.Name).ToListAsync(); var parallelCustomerTask = dbParallel2.Customer.Where(x => x.Name.Contains("7")).OrderByDescending(x => x.Name).ToListAsync();
await Task.WhenAll(parallelSupplierTask, parallelCustomerTask);
https://juldhais.net/super-fast-query-in-entity-framework-6d20cd5358e2
https://stackoverflow.com/questions/41749896/ef-6-how-to-correctly-perform-parallel-queries
Also use AsNoTracking when using EF
Excellent Q & A. See all the answers.
https://stackoverflow.com/questions/34375696/executing-tasks-in-parallel
The 109 answer is a really nice example:
https://stackoverflow.com/questions/12343081/run-two-async-tasks-in-parallel-and-collect-results-in-net-4-5
Comments
Post a Comment