针对 NHibernate 限制测试内存中集合
我的应用程序允许用户在运行报告之前进行一些相当深入的过滤器编辑。我有一个完整的框架来根据这些过滤器动态生成 NHibernate 限制并运行查询。
我遇到的情况是,我对要提取的记录有一组限制,还有另一组限制来标识该组中应接受特殊处理的记录。
目前我能做的最好的事情就是从数据库中提取这两个集合,并且当我处理第一个集合时,我必须检查第二个集合是否包含该元素,以查看是否需要应用我的特殊处理。这里明显的问题是我必须访问数据库两次。
如果我可以在不访问数据库的情况下根据限制查询实体,那就更好了。 NHibernate 有任何工具可以做到这一点吗?
My application allows a user to do some pretty in depth filter editing before they run a report. I have a whole framework to dynamically generate NHibernate restrictions based on these filters, and to run the query.
I have a situation where I have one set of restrictions for the records I want to pull, and another set of restrictions to identify records within that set that should receive special processing.
Currently the best I can do is pull both sets from the database, and as I am processing the first set I must check if the second set contains the element to see if I need to apply my special processing. The obvious problem here is that I must hit the database twice.
It would be much nicer if I could query an entity against a restriction without hitting the database. Does NHibernate have any facility for doing this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
一旦有了内存中的集合,为什么不使用 LINQ-to-objects?
Once you have an in-memory collection, why not use LINQ-to-objects?