Print Page | Close Window

GroupBy with Sum

Printed From: IdeaBlade
Category: DevForce
Forum Name: DevForce 2012
Forum Discription: For .NET 4.5
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=3831
Printed Date: 19-Apr-2025 at 7:09pm


Topic: GroupBy with Sum
Posted By: gregweb
Subject: GroupBy with Sum
Date Posted: 01-Dec-2012 at 7:12pm

I am trying to do a report that groups orders by date and sums them.

In SQL I would write: Select Sum(Orders.Amount) from Orders Group By Orders.Date

The sum works OK, but I don't see how to do the group by.

var op = this.EntityManager.Orders.AsScalarAsync().Sum(a=> a.Amount).GroupBy(a=> a.Date);

Greg



Replies:
Posted By: gregweb
Date Posted: 02-Dec-2012 at 6:40am
I found a good example http://www.ideablade.com/forum/forum_posts.asp?TID=2577&title=best-practice-for-aggregate-functions - here


Posted By: sbelini
Date Posted: 03-Dec-2012 at 6:48am
Hi Greg.

Thanks for the update.

sbelini



Print Page | Close Window