Retrieving with JoinQueryOver: Get Great Children, Know Father

Object structure: The house has many rooms. The room has many tables. There are many vases in the table (on it).

Home> Rooms> Tables> Vases.

I would like to use JoinQueryOver to select all tables with red vases - in a specific house.

I thought of doing this:

var v = session.QueryOver<House>() .Where(x => x.ID == HouseID) .JoinQueryOver<Room>(x => x.Rooms) .JoinQueryOver<Table>(x => x.Tables) .JoinQueryOver<Vase>(x => x.Vases) .Where(x => x.Color == "Red") .SingleOrDefault<House>(); 

This was the approach I tried (out of many that failed). I really do not want information about the house and room.

Ultimately, I am looking for a list of tables (in a specific house) with their collections of vases (red).

Thanks for the help!

Edit

Something like this would be nice:

 var v = session.QueryOver<Table>() .Where(x => x.Room.House.ID == HouseID) // this Where won't work. .JoinQueryOver<Vase>(x => x.Vases) .Where(x => x.Color == "Red") .List().ToList(); 
+4
source share
1 answer
 var v = session.QueryOver<Table>() .JoinAlias(x => x.Room, () => room) .Where(() => room.House.ID == HouseID) .JoinQueryOver<Vase>(x => x.Vases) .Where(x => x.Color == "Red") .List(); 
+8
source

All Articles