With employees and subordinates - I want to load an employee with the count of subordinates in one query.
public class Employee
{
public Name {get;set;}
public int NumberOfSubordinates {get;set;}
}
Resulting SQL should look like :
select e.name, (select count(*) from subordinate s where s.employee_id = e.id) NumberOfSubordinates
from employee e
group by e.name
order by NumberOfSubordinates desc