I have setup delegates for the following OrmLiteConfig Actions:
BeforeExecFilter SqlExpressionSelectFilter
I have also created a ExecFilter that overrides the Exec operation.
The delegates and Exec operation are executed as expected for ‘most’ ORMLite extensions. However, when we use ‘ExecuteSqlAsync’ to execute raw SQL or we use the Dapper extension ‘QueryAsync’ the delegates and Exec operation are never invoked. Is this by design? If so, could you please recommend a way to globally capture the SQL prior to its execution?
The Dapper included in OrmLite is the stock Dapper code from the Dapper connection, it has no connection with OrmLite other than both add extension methods over IDbConnection so you can easily access features in each ORM when you need to.
You can use ExequteSqlAsync or async API versions like SqlListAsync, SqlScalarAsync, etc to execute custom SQL in OrmLite.
You can’t capture Dapper SQL unless you use a DB Profiler like in Mini Profiler or a SQL Profiler for your database.
I appreciate the quick response. Quite frankly, your response time is unparalleled.
This explains why we are seeing the described behavior when using the Dapper extensions. However, when we use the ‘ExecuteSqlAsync’ extension, the delegates associated with OrmLiteConfig.BeforeExecFilter and OrmLiteConfig.SqlExpressionSelectFilter are not being invoked.
Is this by design? Or does it need to be configured differently when using these extensions?