views:

24

answers:

0

I'm trying to use nhibernate's query by example to build dynamic queries. I'm stuck on how to code for an example object with multiple associations. Here's an example from NHibernate in Action. Its a 'User' object with a property 'Items'.

Example exampleUser =
Example.Create(u).IgnoreCase().EnableLike(MatchMode.Anywhere);
Example exampleItem =
Example.Create(i).IgnoreCase().EnableLike(MatchMode.Anywhere);
return GetSession().CreateCriteria(typeof(User))
.Add( exampleUser )
.CreateCriteria("Items")
.Add( exampleItem )
.List<User>();

If the User object has let's say a Category object as a property, how could I add that in to the above example? If i put another CreateCriteria at the end it refers to the Items, not the User.