NHibernate Lazy=“额外" [英] NHibernate Lazy="Extra"
问题描述
对lazy="extra" 到底能做什么有很好的解释吗?
Is there a good explanation out there on what exactly lazy="extra" is capable of?
我看过的所有帖子都只是重复这样一个事实,即它将对 MyObject.ItsCollection.Count
的引用转换为 select count(*) 查询(假设它们尚未加载).
All the posts I've seen all just repeat the fact that it turns references to MyObject.ItsCollection.Count
into select count(*) queries (assuming they're not loaded already).
我想知道它是否具有更强大的功能,例如将 MyObject.ItsCollection.Any(o => o.Whatever == 5)
转换为 SELECT ...EXISTS
查询.
I'd like to know if it's capable of more robust things, like turning MyObject.ItsCollection.Any(o => o.Whatever == 5)
into a SELECT ...EXISTS
query.
文档的第 18.1 节仅涉及它.我不是 NH 开发人员,所以我无法真正试验它并观看 SQL Profiler,而无需做一些工作来设置所有内容;我只是在寻找某种描述此功能功能的参考资料.
Section 18.1 of the docs only touches on it. I'm not an NH developer, so I can't really experiment with it and watch SQL Profiler without doing a bit of work getting everything set up; I'm just looking for some sort of reference describing what this feature is capable of.
谢谢!
推荐答案
对于 2.x 版本,它仅用于将 collection.Count()
转换为 select count
code> 并且就我在源代码中看到的而言,它还允许构造 collection[5]
获取该特定实体(具有索引 5),而不是对整个集合进行补水.
for version 2.x it is only used to translate a collection.Count()
into a select count
and as far as i can see in the source, it will also allow the construct collection[5]
to fetch that particular entity (with index 5) instead of hydrating the whole collection.
对于 3.x 版,我在发行说明中没有看到任何相关内容
For version 3.x i didn't see anything related in the release notes
这篇关于NHibernate Lazy=“额外"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!