-1

下記のSQLに相当するNHibernateQueryOverを作成するための助けをいただければ幸いです。

select sum(s.StudentCount),sum(w.TotalEarningsAmount),
avg(w.TotalEarningsAmount),count(w.TotalEarningsAmount) 
from School s inner join s.Earnings w where s.Active = 1"
4

1 に答える 1

3
Earning w = null; //alias variable
Dto dto = null; //make a dto object

var dtoList = Session.QueryOver<School>()
    .JoinAlias(x => x.Earnings, () => w)
    .Where(x => x.isActive)
    .SelectList(list => list
        .SelectSum(x => x.StudentCount).WithAlias(() => dto.StudentCountSum)
        .SelectSum(() => w.TotalEarningsAmount).WithAlias(() => dto.TotalEarningsAmountSum)
        .SelectAvg(() => w.TotalEarningsAmount).WithAlias(() => dto.TotalEarningsAmountAvg)
        .SelectCount(() => w.TotalEarningsAmount).WithAlias(() => dto.TotalEarningsAmountCount))
    .TransformUsing(Transformers.AlaisToBean<Dto>())
    .List<Dto>();
于 2012-12-17T17:40:43.200 に答える