LINQ查询问题

时间:2009-06-09 03:33:28

标签: c# sql linq

我想要一个等效的 linq to object 查询以下的sql查询

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

提前致谢

1 个答案:

答案 0 :(得分:2)

我认为这是正确的。但是没有经过测试。

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) };