When must we use eager loading in NHibernate? What is it's usage?

谁说胖子不能爱 提交于 2020-01-06 11:45:14

问题


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

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