Hi.
I want to query an object that has a collection and have that collection be fetched with the constraints in the query.
I mean:
I have a Grantee object that has a Grant collection, Grant has among others a Year property. I want to fetch all Grantees with Grant.Year > xxxx
I have this criteria query:
Code:
ICriteria granteeCrit = s.CreateCriteria(typeof(Grantee));
ICriteria grantCrit = granteeCrit.CreateCriteria("Grants");
grantCrit.Add(Expression.Ge("Year", year));
granteeCrit
.Add(Expression.Eq("Active", true))
.AddOrder(Order.Asc("LastName"))
.AddOrder(Order.Asc("FirstName"));
IList<Grantee> a = granteeCrit.List<Grantee>();
The thing is, when I do a foreach on Grantee.Grants the collection has all of the elements, not just the ones where Year > xxxx
Is there any way to constraint the collection on the query?
Thank you very much
Alex