问题
When must we use eager loading in NHibernate? What is it's usage?
回答1:
One usage is when you will cache or store an object graph (in ASP.NET Cache for instance). If you don't store the whole graph, you would be missing information on a detached object. You can reattach objects of course, but that would probably be a new roundtrip to the database anyway.
If you don't eager load your collections, you would need to touch every one of the to invoke the lazy fetch. In those cases, an eager fetch is much more useful.
回答2:
Maybe this presentation by Udi can help you decide.
http://www.infoq.com/presentations/Making-Roles-Explicit-Udi-Dahan
来源:https://stackoverflow.com/questions/2989058/when-must-we-use-eager-loading-in-nhibernate-what-is-its-usage