I am trying to create a query that orders a child collection property. In SQL, this is pretty simple:
Select Table1.*
From Table1
Inner join Table2 on Table1.Id = Table2.Table1Id
OrderBy Table1.Column1, Table2.Column1
Here's how I did it in NHibernate 2, and it worked fine:
var result = Session.Linq<Table1>()
.OrderBy(x => x.Column1)
.ThenBy(x => x.Table2.FirstOrDefault().Column1);
After upgrading to NHibernate 3, this no longer works. It throws NHibernate.Hql.Ast.ANTLR.QuerySyntaxException: Antlr.Runtime.NoViableAltException.
I am using NHibernate 3.1. Are there other solutions for such a request?
source
share