Linq-to-NHibernate OrderBy not working

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.

+3
source share
1

, . " by" .

SQL :

select id, sum(child.parentid) as childsum from dbo.Parent
inner join child on
parent.id= child.parentid 
group by id
order by childsum desc

Linq2NH ... . HQL, , , .

Linq2NH , . , . ( , 6 - , , , !) , . HQL: , .

+2

Source: https://habr.com/ru/post/1721819/


All Articles