NHibernate Projections - how to project collections?

51 views
Skip to first unread message

Chuck Boyde

unread,
May 14, 2012, 1:20:34 AM5/14/12
to nhusers
Have a scenario where I need to only select a few properties from an
entity, but also collections. This seems 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
Reply all
Reply to author
Forward
0 new messages