Dears, I have a method which loads few tables. I would like to execute them all in the same time .. not one after another..
my code below:
public async Task FillViewModelDataAsync(out IndexViewModel vm)
{
vm.Areas = await _context.Areas.Where(x => x.IsDisabled == false).ToDictionaryAsync(x => x.Id, y => y.Name);
vm.SubAreas = await _context.SubAreas.Where(x => x.IsDisabled == false).ToDictionaryAsync(x => x.Id, y => y.Name);
vm.WorkCenters = await _context.Workcenters.Where(x => x.IsDisabled == false).ToDictionaryAsync(x => x.Id, y => y.Name);
vm.Priorities = await _context.Priorities.Where(x => x.IsDisabled == false).ToDictionaryAsync(x => x.Id, y => y.Name);
vm.Departments = await _context.DepartmentToWorkcenters.Get().Where(x => x.IsDisabled == false).ToDictionaryAsync(x => x.Id, y => y.Name);
}
I guess I should create a list of tasks and later wait.all()... am I right? How to do it correctly?