KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I want to sum up three different fields of a table in one query. I want a linq equivalent of this T-SQL: select sum(fld1), SUM(fld2), SUM(fld3) from MyTable where classID = 5 All examples I have found either use a group by or call the query multiple times, once for each field that needs to be summed up. I have something like this now. But I don't want to add a group by clause to it as it is not required in its T-SQL form. from a in MyTable where a.classID == 5 group a by a.classID into g select new { Sumfld1 = g.Sum(x => x.fld1 ), Sumfld2 = g.Sum(x => x.fld2), Sumfld3 = g.Sum(x => x.fld3) } Any suggestions? Thanks for your time.
Tags (comma-separated)
Save Edits
Cancel