hi all, been struggling with this for a while, and cant seam to figure it out...
i've got a BlogPost class, which has a collection of Comments, and each of the comments has a DatePosted field.
what i need to do is query for a BlogPost and return it with a partially loaded Comments collection, say all comments posted on the 1 Aug 2009.
i've got 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 out the sql generated, it first runs a query against the BlogPost table, joining to the Comment table with the correct date restriction in, then runs a second query just on the Comment table that returns everything.
result is the Comments collection of the BlogPost class totally filled up!
what am i doing wrong?
i've got code samples if anyone needs more info...!