This article explains the usage of Dapper.
In the ExecuteAsync section the author writes after this example:
public async Task<int> UpdateSalesOrder(int salesOrderId, byte status)
{
const string sql = @"
UPDATE Sales.SalesOrderHeader
SET STATUS = @status
WHERE SalesOrderID = @salesOrderId";
var param = new {status, salesOrderId};
using var conn = _db.GetAdventureWorksConnection();
return await conn.ExecuteAsync(sql, param)
.ConfigureAwait(false);
}
It is best to nuke any synchronization with the main thread at the data access layer because this can affect scalability. Therefore, it is a good idea to set configure await to false, so this does not wait on the main thread. Unfortunately, C# does not do this automatically for the developer, so it must come from muscle memory. A good rule of thumb is if you are working in the DAL, put ConfigureAwait(false) in every call stack method.
Does this advice apply only to code that interacts with Db in the way that Dapper does? Can someone please explain in which scenario C# does this automatically?
If this code is part of a class library which would then be used in any type of .Net Application what would be the implications?
Regards.