我尝试使用Nhibernate v.4运行如下查询:
Select o.Number, c.Address
From Order o join Client c on o.ClientId = c.Id
Where c.Name = "John"
使用JoinQueryOver和JoinAlias尝试了多种方法,但没有任何帮助,最终出现错误“无法解析属性:订单地址”
Session.QueryOver<Order>()
.JoinQueryOver(s => s.Client)
.Where(() => c.Name == "John")
.SelectList(x => .Select(Projections.Property<Order>(o => o.Number)
.SelectList(x => .Select(Projections.Property<Order>(o => o.Client.Address))
或者像这样
...
.SelectList(x => .Select(Projections.Property<Order>(o => o.Number)
.SelectList(x => .Select(Projections.Property<Client>(c => c.Address))
构建查询或类似查询的正确方法是什么?“Select”操作符出现问题,“Where”部分工作正常。我还可以通过这两个彼此独立的实体构建非连接查询,它工作得很好,但不知道如何连接它们