Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add groupby in query over nhibernate?

How can I add groupby Id to this nhibernate code because I'm new with it and there is many way but none work for me.

.Select(Projections.Sum(() => ServiceOrderItem.WorkTime), 
    Projections.ProjectionList().Add(Projections.Property(
        () => ServiceOrder.Id).WithAlias(() => TechnicianWorkTime.Id))
    )

There will be more in ProjectionList...

like image 938
Endiss Avatar asked May 15 '12 14:05

Endiss


1 Answers

You can use SelectList for it:

query.SelectList(list => list
  .SelectGroup(() => ServiceOrder.Id)
  .SelectSum(() => ServiceOrderItem.WorkTime));
like image 185
Anton Avatar answered Oct 31 '22 13:10

Anton