Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NHibernate 3 lazy properties and eager queries

I'm using NHibernate 3.0.0 and the new feature lazy properties. However, in some queries I want to eagerly load the properties and I would like the query to result in non-proxied entity instances. I also prefer to use the LINQ provider or QueryOver. So my two questions related to this are:

  1. I know that eager loading of properties can be achieved in HQL with "fetch all properties" but is it possible to do the same with the LINQ provider or QueryOver?
  2. If I execute an HQL query with "fetch all properties" the entities in the result are indeed eagerly loaded but they are still proxied. Is there a way of avoiding this?

Cheers

like image 469
Yhrn Avatar asked Jan 28 '11 08:01

Yhrn


1 Answers

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.

like image 86
Phill Avatar answered Oct 03 '22 07:10

Phill