Well, such a task is a Task of void. A method like so...
public void WorkshopNcoaIdUpdate(int id, string nocaId)
{
foreach (var workshop in _context.Workshops.Where(w => w.Id == id))
{
workshop.NcoaId = nocaId;
}
_context.SaveChanges();
}
...may be rewritten like so and doing so allows the method to run asynchronously.
public async Task WorkshopNcoaIdUpdate(int id, string nocaId)
{
foreach (var workshop in _context.Workshops.Where(w => w.Id == id))
{
workshop.NcoaId = nocaId;
}
await _context.SaveChangesAsync();
}
No comments:
Post a Comment