문제

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?

도움이 되었습니까?

해결책

I've actually asked the exact same question here on SO, and posted the answer that I found.

다른 팁

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();
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top