我有一个场景,我只需要从一个实体中选择一个或几个列,但在一个查询中选择多个子列。我一直在尝试投影,但是在集合属性上得到了一个错误。这是一种正常的情况,但是找不到关于投影仅限集合的属性的信息。
Customer customerAlias = null;
Order orderAlias = null;
var list = _session.QueryOver<Customer>(() => customerAlias)
.JoinAlias(x => x.Orders, () => orderAlias, JoinType.LeftOuterJoin)
.Select(
Projections.Property(() => customerAlias.Name),
Projections.Property(() => customerAlias.Orders))//this is the issue
.List<object>();返回的错误为:
System.IndexOutOfRangeException : Index was outside the bounds of the array发布于 2012-06-09 16:21:58
在NH3.3中不能这样做。https://nhibernate.jira.com/browse/NH-3176
发布于 2012-05-20 21:20:12
反转查询如何(假设订单有一个客户属性):
var list = _session.QueryOver<Order>()
.Select(
Projections.Property(o => o.Customer.Name),
Projections.Property(o => o.OrderProperty1),
Projections.Property(o => o.OrderProperty2)) // etc..
.List<object[]>();https://stackoverflow.com/questions/10563804
复制相似问题