select T.Id, count(Th.ampount)
from TH, T
where Th.Tid= T.id
group by T.Id
如何使用流畅的nhibernate编写上述查询。我不想使用CreateSQLQuery()。
答案 0 :(得分:-1)
session.QueryOver<TH>()
.JoinAlias(th => th.Ts, () => tAlias)
.SelectList(list => list
.SelectGroup(th => th.Id)
.SelectCount(() => tAlias.amount)
// or did you mean
.SelectSum(() => tAlias.amount)
)
.List<object[]>();