Home > front end >  How is this SQL statement done with Entity Framework? SUM column in Entity Framework
How is this SQL statement done with Entity Framework? SUM column in Entity Framework

Time:07-04

This is my table:

https://img.codepudding.com/202207/e91f162b42dd4175bec4b5e4008a4489.png

How is this SQL statement done with Entity Framework:

https://img.codepudding.com/202207/4cc1ed48035448faa7fb9464480f6e13.png

I appreciate any help

CodePudding user response:

Method Syntax:

var result = yourTable.GroupBy(i => i.ProductoId)
                           .Select(g => (g.Key,g.Sum(ing => ing.SumaUnidadesIngresados))

Query syntax:

var result = from i in ingresosStock
             group i by i.ProductoId into gr
             select (gr.Key, gr.Sum(s => s.SumaUnidadesIngresados))
  • Related