I am trying to order a Linq request for NHibernate for the amount of his children.
session.Linq<Parent>().OrderBy( p => p.Children.Sum( c => c.SomeNumber ) ).ToList()
This does not work. When I look at NHProf, I see that it orders Parent.Id. I thought that maybe he was returning the results and ordering them outside of SQL, but if I add .Skip (1). Enter (1) into the Linq query, it still orders Parent.Id.
I tried to do this using a list in memory, and it works just fine.
Am I doing something wrong, or is it a Linq issue for NHibernate?
I am sure that I can always return the list and then perform operations on them, but this is not an ideal workaround because I do not want to return all the records.
source
share