I want to update a field by a lambda expression like this:
packageWorkshopDtos.ForEach(p => p.WorkshopDto.ForEach(
u => u.SubCategories = _context.School_Categories
.Where(j => j.ParentCategoryId == u.CategoryId)
.Select(c => c.Name)
.ToList()));
For making this asynchronous, I did this:
packageWorkshopDtos.ForEach(p => p.WorkshopDto.ForEach(
async u => u.SubCategories = await _context.School_Categories
.Where(j => j.ParentCategoryId == u.CategoryId)
.Select(c => c.Name)
.ToListAsync()));
But it gives me this error:
Message "A second operation was started on this context instance before a previous operation completed. This is usually caused by different threads concurrently using the same instance of DbContext.
How can I make it asynchronous?