class parent
{
virtual AnotherType AnotherType {get;set;}
virtual TypeA TypeA {get;set;}
virtual IList<TypeB> TypeBs {get;set;}
}
class TypeA
{
virtual TypeC TypeC {get;set;}
...
}
class TypeB
{
virtual TypeD TypeD {get;set;}
...
}
需要通过过滤TypeA和TypeB
来返回不同的父列表select p.*
from parent p
join typea a on a.parentid = p.parentid
join typeb b on b.parentid = p.parentid
join typec c on c.typeaid = c.typeaid
join typed d on d.typebid = d.typebid
where p.AnotherType.id = "someid"
and c.foo == "foo"
and d.bar == "bar"
尝试使用
Session.QueryOver(() => parent)
.joinalias(() => parent.TypeA, () => typea)
.joinalias(() => typea.TypeC, () => typec)
.joinalias(() => parent.TypeB, () => typeb)
.joinalias(() => typeb.TypeD, () => typed)
.where(() => parent.AnotherType.id == "someid")
.and(() => typec.foo == "foo")
.and(() => typed.bar == "bar).Future<parent>.ToArray();
但是我得到了重复,因为typeB被平铺到结果中而不是单独作为父集合查询。
答案 0 :(得分:0)
使用
过滤重复项Session.QueryOver(() => parent)
...
.TransformUsing(Transformers.DistinctRootEntity)
.Future<Parent>().ToArray();