I struggled with this for a while and cannot understand what it is ...
I have a class BlogPostthat has a collection Comments, and each of the comments has a field DatePosted.
I need to make a request for BlogPostand return it with a partially loaded collection Comments, say, all comments posted on August 1, 2009.
I have this query:
BlogPost post = session.CreateCriteria<BlogPost>()
.Add(Restrictions.Eq("Id", 1))
.CreateAlias("Comments", "c")
.Add(Restrictions.Eq("c.DatePosted", new DateTime(2009, 8, 1)))
.UniqueResult<BlogPost>();
When I run this query and check the generated sql, it first launches the query on the table BlogPost, joining the table Commentwith the correct date limit in, then runs the second query only on Comment, which returns everything.
The result is a complete collection of the Commentsclass BlogPost!
?
, - ...!
Chris Browne