【发布时间】:2012-08-28 14:11:29
【问题描述】:
我正在尝试让 nhibernate 在急切的获取中使用别名。我不确定它是否可能。
我正在尝试在我的提取中使用别名(在我的示例中为 bAlias)。
QueryOver<A>()
.JoinAlias(x => x.B, () => bAlias)
.JoinAlias(x => x.B, () => bAlias2)
.Where(() => bAlias2.Surname == "Smith")
.Fetch(() => bAlias).Eager
.Fetch(() => bAlias.C).Eager;
如您所见,获取命令使用 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的别名?
标签: nhibernate queryover