nreco / data

Fast DB-independent DAL for .NET Core: abstract queries, SQL commands builder, schema-less data access, POCO mapping (micro-ORM).
https://www.nrecosite.com/dalc_net.aspx
MIT License
184 stars 39 forks source link

Ability to log/intercept IDbCommand before execution in DbDataAdapter #38

Closed VitaliyMF closed 7 years ago

VitaliyMF commented 7 years ago

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).

VitaliyMF commented 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