Endiss Endiss - 1 year ago 124
ASP.NET (C#) Question

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),
() => ServiceOrder.Id).WithAlias(() => TechnicianWorkTime.Id))

There will be more in ProjectionList...

Answer Source

You can use SelectList for it:

query.SelectList(list => list
  .SelectGroup(() => ServiceOrder.Id)
  .SelectSum(() => ServiceOrderItem.WorkTime));
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download