nhibernate拦截select查询
我正在看 nhibernate 拦截器。它似乎能够拦截保存、更新和删除查询,但无论如何我可以拦截选择查询。
我遇到的问题是,在某些情况下,我会自动将一些额外的 sql 过滤器附加到正在执行的 sql 语句中。
有什么想法
谢谢 垫
I'm looking at the nhibernate interceptor. It seems to be able to intercept save, update and delete queries but is there anyway I can intercept a select query.
The problem I have is that I automatically want to append some additional sql filters to the executing sql statement in certain cases.
Any thoughts
Thanks
Mat
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
拦截器框架仅允许您拦截实体操作,例如保存、更新和删除。查询本身不会被拦截,只有实体操作(选择/查看不算)。
考虑对附加到 ICriteria 的一组查询类使用某种继承来满足您的目的。
The interceptor framework only allows you to intercept entity operations like save, update, and delete. Queries themselves aren't intercepted, only entity operations (and selecting/viewing doesn't count).
Consider using some sort of inheritance for a set of query classes that append to your ICriteria to suit your purposes.
我认为你可以使用自定义 NHibernate 持久器来实现这一点;但是,我很难找到有关如何编写示例的示例......
I think you can accomplish that with a custom NHibernate persister; however, I'm having trouble finding examples on how you'd write one...
您可以在
class
标记上使用where
属性:You can use the
where
attribute on theclass
tag: