Closed VitaliyMF closed 7 years ago
It is possible to intercept DbCommand
for logging / collecting performance metrics with the current API: by extending DbFactory
and overriding CreateCommand
method. This override may wrap real command with special proxy class that handles ExecuteNonQuery/ExecuteScalar/ExecuteReader and performs all necessary logging actions.
This approach is illustrated in the SqlLogging example: https://github.com/nreco/data/tree/master/examples/SqliteDemo.SqlLogging
Currently it is not possible to get IDbCommand instance that is internally produced by DbDataAdapter. This might be useful in the following scenarios:
Technically this might be a delegate (or protected method to override).