Why is IDbCommandTreeInterceptor being skipped on second query?

半城伤御伤魂 提交于 2019-12-11 12:49:22

问题


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:


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.



来源:https://stackoverflow.com/questions/46650065/why-is-idbcommandtreeinterceptor-being-skipped-on-second-query

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!