Why is IDbCommandTreeInterceptor being skipped on second query?

140 views Asked by At

Using entity framework I have implemented soft delete & data level restriction with IDbCommandTreeInterceptor. For the first query using the context, the interceptor gets hit. But trying again (refreshing browser), the interceptor is skipped. I have checked whether data is being cached by changing some data using SQL server management studio. The changes are reflected but the interceptor is still skipped. What could possibly be causing for this to happen?

1

There are 1 answers

2
jbl On BEST ANSWER

according to the sources comments this is expected behaviour

Command trees are created for both queries and insert/update/delete commands. However, query command trees are cached by model which means that command tree creation only happens the first time a query is executed and this notification will only happen at that time

As a consequence your interceptor result can not depend on the data.