3

The linq provider in Nhibernate 3 gives me the ability to specify eager fetching of multiple levels for collections using FetchMany, ThenFetchMany etc. Is there an equivalent way of doinf this using QueryOver.

Say I have a structure

class  A
{
  IList<B> b;
}

class B
{
  IList<C> c;
}

class C
{

}

I can eager load the whole tree in NH Linq

session.Query<A>
       .FetchMany(x=> a.b)
       .ThenFetchMany(y => y.c)
       .ToList();

Is there a way of doing this using the QueryOver api?

ilias
  • 2,620
  • 2
  • 27
  • 37

1 Answers1

0
B bAlias = null;
C cAlias = null;
var list = session.QueryOver<A>
.JoinAlias(x=>x.b, () => bAlias, JoinType.LeftOuterJoin)
.JoinAlias(x=>bAlias.c, () => cAlias, JoinType.LeftOuterJoin)
.List();
Samuel Goldenbaum
  • 18,391
  • 17
  • 66
  • 104