OrderBy FirstOrDefault LINQ statement. Throwing runtime exception

Description

I am writing a LINQ statement sort the order of an embedded list, PACKAGE_REVIEWS, which belongs to the parent ACTIVITY_PACKAGE. When I run the code, it throws an exception for the following code:

1 daACTIVITY_PACKAGE.GetData().Where(x => x.ACTIVITY.ACTIVITY_UID == activityId).OrderBy(o => o.PACKAGE_REVIEWS.FirstOrDefault().SORT_ORDER);

There are two PACKAGE_REVIEWS record. I am not sure what is causing the exception. How can I rewrite to fix the issue? Any help is appreciated.

1 2 3 4 Exception of type 'Antlr.Runtime.NoViableAltException' was thrown. [.OrderBy[OFAC.FOIA.BusinessEntities.NHObjects.ACTIVITY_PACKAGE,System.Int32](.Where[OFAC.FOIA.BusinessEntities.NHObjects.ACTIVITY_PACKAGE](NHibernate.Linq.NhQueryable`1[OFAC.FOIA.BusinessEntities.NHObjects.ACTIVITY_PACKAGE], Quote((x, ) => (Equal(x.ACTIVITY.ACTIVITY_UID, p1))), ), Quote((o, ) => (.FirstOrDefault[OFAC.FOIA.BusinessEntities.NHObjects.PACKAGE_REVIEW](o.PACKAGE_REVIEWS, ).SORT_ORDER)), )] Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: NHibernate.Hql.Ast.ANTLR.QuerySyntaxException: Exception of type 'Antlr.Runtime.NoViableAltException' was thrown. [.OrderBy[OFAC.FOIA.BusinessEntities.NHObjects.ACTIVITY_PACKAGE,System.Int32](.Where[OFAC.FOIA.BusinessEntities.NHObjects.ACTIVITY_PACKAGE](NHibernate.Linq.NhQueryable`1[OFAC.FOIA.BusinessEntities.NHObjects.ACTIVITY_PACKAGE], Quote((x, ) => (Equal(x.ACTIVITY.ACTIVITY_UID, p1))), ), Quote((o, ) => (.FirstOrDefault[OFAC.FOIA.BusinessEntities.NHObjects.PACKAGE_REVIEW](o.PACKAGE_REVIEWS, ).SORT_ORDER)), )]

Environment

Windows 7 64B

Status

Assignee

Unassigned

Reporter

John Yee

Labels

Components

Affects versions

4.0.3

Priority

Trivial
Configure