Have a scenario where I need to only select a single/few columns from an entity, but multiple children in a query. I have been trying with projections but getting an error on the collections property. This is such a normal situation, yet cannot find info on projecting collections - only properties.
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>();
Error returned is:
System.IndexOutOfRangeException : Index was outside the bounds of the array
Cannot be done in NH 3.3. https://nhibernate.jira.com/browse/NH-3176
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With