NHibernate 3 lazy properties and eager queries

我与影子孤独终老i 提交于 2019-12-04 04:12:32

For question 1: The answer is no, 'fetch all properties' as described in http://ayende.com/blog/4377/nhibernate-new-feature-lazy-properties is currently only supported in HQL.

I do remember seeing in the NH Google Discussions somewhere, I'm unable to find the thread. Will update answer if I can find it today. But as of the current 3.1 release it's only in HQL.

For question 2: I don't know if there is a way to avoid this, I usually transform them to DTO's and serialize the DTO, not the NH Poco, when using WCF. Leonardo's link looks interesting and may be able to help.

Leonardo Cardoso

You can use this http://davybrion.com/blog/2009/03/must-everything-be-virtual-with-nhibernate/ to disable de lazy load of your classes (no proxies)
You can use this http://nhibernate.info/doc/nh/en/index.html#querycriteria-dynamicfetching to eager load your properties
Or you can try this http://www.timvasil.com/blog14/post/2008/02/WCF-serialization-with-NHibernate.aspx and still use the proxies.

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