tags:

views:

134

answers:

1
+1  Q: 

LINQ QUERY PROBLEM

I want an equivalent linq to object query for the below sql query

SELECT SUM(AMOUNT)
FROM ACCOUNTS a
INNER JOIN  DETAIL d ON a.CODE = d.CODE
INNER JOIN  ACCENTRIES e ON d.EID= e.EID and e.EDATE > '1/1/2000'
GROUP BY d.CODE

Thanks in advance

+2  A: 

I think this is correct. Not tested, though.

from a in ACCOUNTS 
     join ed in ENTRIESDETAIL on a.ACODE equals ed.ACODE
     join e in ENTRIES on e.EID equals ed.EID
     where e.EDATE > DateTime.Parse("1/1/1990")
     group ed by ed.ACODE into g
     select new { g.Group.Sum(s => s.EDAMOUNT) };
Robert Harvey