@canton7's response answers the original question.
Dapper doesn't have interceptors, so to solve your real problem (add logging) you have two options:
1. Make own extension methods (bad option):
Make methods like .LoggingQueryAsync(...)
.
It looks simple at first, but have way too many downsides...
2. Implement IDbConnection
method that Dapper calls (good option):
public class LoggingDbConnection : IDbConnection
{
...
public IDbCommand CreateCommand()
{
return new LoggingDbCommand(this);
}
...
}
Dapper have to call IDbConnection.CreateCommand()
to do anything.
In LoggingDbCommand
implement IDbCommand.ExecuteNonQuery()
, IDbCommand.ExecuteReader()
, IDbCommand.ExecuteReader(CommandBehavior)
and IDbCommand.ExecuteScalar()
to add logging.