我试图让nhibernate在渴望获取中使用别名。林不知道它可能。Nhibernate QueryOver在Eager Fetch中使用别名
我想在我的提取中使用别名(在我的例子中是bAlias)。
QueryOver<A>()
.JoinAlias(x => x.B,() => bAlias)
.JoinAlias(x => x.B,() => bAlias2)
.Where(() => bAlias2.Surname == "Smith")
.Fetch(() => bAlias).Eager
.Fetch(() => bAlias.C).Eager;
正如你所看到的,fetch命令使用2个别名而不是直接路径。
上述代码无效。可以工作的代码是
QueryOver<A>()
.JoinAlias(x => x.B,() => bAlias)
.JoinAlias(x => x.B,() => bAlias2)
.Where(() => bAlias2.Surname == "Smith")
.Fetch(x => x.B).Eager
.Fetch(x => x.B.C).Eager;
正如您所看到的,它的Fetch语句不同。
为什么您需要使用'JoinAlias'中的别名? –