I'm trying order a Linq to NHibernate query by the sum of it's children.
session.Linq<Parent>().OrderBy( p => p.Children.Sum( c => c.SomeNumber ) ).ToList()
This does not seem to work. When looking at NHProf, I can see that it is ordering by Parent.Id. I figured that maybe it was returning the results and ordering them outside of SQL, but if I add a .Skip ( 1 ).Take( 1 ) to the Linq query, it still orders by Parent.Id.
I tried doing this with an in memory List and it works just fine.
Am I doing something wrong, or is this an issue with Linq to NHibernate?
I'm sure I could always return the list, then do the operations on them, but that is not an ideal workaround, because I don't want to return all the records.