what is the linq equivalent of the following:
SELECT Mytable.A, MyTable.B, SUM(MyTable.C)
FROM MyTable
GROUP BY Mytable.A, MyTable.B
ORDER BY Mytable.A, MyTable.B
This is trivial in SQL, but seems to be very difficult in LINQ. What am I missing?
what is the linq equivalent of the following:
SELECT Mytable.A, MyTable.B, SUM(MyTable.C)
FROM MyTable
GROUP BY Mytable.A, MyTable.B
ORDER BY Mytable.A, MyTable.B
This is trivial in SQL, but seems to be very difficult in LINQ. What am I missing?
I don't have access to Visual Studio right now to test it out but it should look like this:
from record in table
group record by new { record.A, record.B } into recGroup
orderby recGroup.Key.A, recGroup.Key.B
select new { recGroup.Key.A, recGroup.Key.B, C = recGroup.Select(p => p.C).Sum() }