如何在查询中添加分组通过 nhibernate
本文关键字:nhibernate 添加 查询 | 更新日期: 2023-09-27 18:34:09
如何将 groupby Id 添加到这个 nhibernate 代码中,因为我是新手,有很多方法,但没有一种对我有用。
.Select(Projections.Sum(() => ServiceOrderItem.WorkTime),
Projections.ProjectionList().Add(Projections.Property(
() => ServiceOrder.Id).WithAlias(() => TechnicianWorkTime.Id))
)
投影列表中将有更多内容...
你可以
使用SelectList
:
query.SelectList(list => list
.SelectGroup(() => ServiceOrder.Id)
.SelectSum(() => ServiceOrderItem.WorkTime));
你也可以这样做:
objQuery = objQuery.SelectList(list => list.SelectGroup((x => x.Id)));