These days it is common for the data layer to interact asynchronously with the DB:
public async Task<Customer> GetCustomer(int id)
{
using (db = new AppDbContext())
{
return await db.Customers.FindAsync(id);
}
}
With this technique, it is my understanding that all calling methods, all the way to the UI layer, then must also be defined with the async keyword. Thus you end up with an application where every method or function that eventually interacts with the DB be an async method.
This seems terribly messy and "pollutes" all the application layers with knowledge of an implementation detail inside the data layer.
Am I misunderstanding something or is this simply what one has to do?