Ambient context implementation for Dapper.
Ambient Context is a little-known pattern which is frequently used by the .NET framework to address cross-cutting concerns such as security (
Thread.CurrentPrincipal), logging (Trace & TraceListeners),
HttpContext and etc. The general idea is that the application sets up a context, typically at an entry-point of an operation or web request, which becomes available to the rest of the system via a static property or method.
Dapper.AmbientContext uses a similar approach to treat the database connection and transaction as resources which are seamlessly shared between various data access components. This pattern works really well with the service layer which consumes multiple data access repositories, commands and queries to perform a variety of database tasks within the same transaction.
More information in the wiki.
Install Dapper.AmbientContext with NuGet