1
SELECT OrderID, SUM(Amount) AS Amount
FROM CustomerOrders
GROUP BY OrderID WITH ROLLUP

How can i convert the above sql into linq?

DavidG
  • 113,891
  • 12
  • 217
  • 223
aNTONY
  • 13
  • 3
  • How about you show us what you have tried so far? – DavidG Aug 09 '16 at 09:49
  • LINQ isn't a replacement for SQL. It is useful as a query language for ORMs (I assume you use EF instead of eg NHibernate?). It's *NOT* a query language for analytical queries as this – Panagiotis Kanavos Aug 09 '16 at 10:11
  • You can execute raw SQL queries with Entity Framework and have it map the result to a class. This is the only way to execute this particular query. Of course, ORMs aren't meant for reporting/analytical queries anyway. A micro-ORM like Dapper would be preferable for such queries as you'll end up creating the query by hand anyway – Panagiotis Kanavos Aug 12 '16 at 07:41
  • This answer can probably help you. https://stackoverflow.com/a/1401623/4444757 – Arani Mar 06 '23 at 05:03

0 Answers0