如何在查询中添加groupby而不是nhibernate?

End*_*iss 4 c# sql asp.net nhibernate queryover

我怎样才能将groupby Id添加到这个nhibernate代码中,因为我是新手,并且有许多方法,但对我来说都没有用.

.Select(Projections.Sum(() => ServiceOrderItem.WorkTime), 
    Projections.ProjectionList().Add(Projections.Property(
        () => ServiceOrder.Id).WithAlias(() => TechnicianWorkTime.Id))
    )
Run Code Online (Sandbox Code Playgroud)

ProjectionList中会有更多...

Ant*_*ton 11

你可以使用SelectList它:

query.SelectList(list => list
  .SelectGroup(() => ServiceOrder.Id)
  .SelectSum(() => ServiceOrderItem.WorkTime));
Run Code Online (Sandbox Code Playgroud)