troubleshooting Question

Linq->EF lambda syntax for sum & group by

Avatar of Alw1n
Alw1n asked on
.NET Programming
4 Comments1 Solution904 ViewsLast Modified:
Hi,
I am struggling with the EF lambda syntax for the following 2 traditional SQL's:

1. select sum(FIELD1), sum(FIELD2) from MYTABLE where FIELD3 = 3
2. select FIELD1, sum(FIELD2), sum(FIELD3) from MYTABLE group by FIELD1

I kinda get the basics of the syntax below but how do I get this all into one data set like the SQL's above would produce?:
        var x = DBContext.MYTABLE.Where(a => a.FIELD3 == 3);
        var d1 = x.Sum(p1 => p1.FIELD1);
        var d2 = x.Sum(p2 => p2.FIELD2);
ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 1 Answer and 4 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 4 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros