5

エンティティから単一/少数の列のみを選択する必要があるが、クエリで複数の子を選択する必要があるシナリオがあります。投影を試しましたが、collectionsプロパティでエラーが発生しました。これは通常の状況ですが、コレクションの投影に関する情報は見つかりません。プロパティのみです。

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
4

2 に答える 2

3

NH3.3では実行できません。https://nhibernate.jira.com/browse/NH-3176

于 2012-06-09T08:21:58.430 に答える
2

クエリを逆にするのはどうですか(OrderにCustomerプロパティがあると仮定します):

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[]>();
于 2012-05-20T13:20:11.657 に答える