我很难弄清楚如何将这个简单的SQL语句转换为(c#)linq到SQL:
SELECT table1.vat, SUM(table1.QTY * table2.FLG01 + table1.QTY * table2.FLG04) FROM table1 inner join table2 on table2.key= table1.key where '2010-02-01' <= table1.trndate and table1.trndate <= '2010-02-28' Group by table1.vat
任何帮助表示赞赏
我仍在学习LINQ,但这似乎可行
var result = from t1 in table1 from t2 in table2 where t1.key == t2.key && DateTime.Parse("2010-02-01") <= t1.trndate && t1.trndate <= DateTime.Parse("2010-02-28") group new {t1,t2} by t1.vat into g select new { vat = g.Key, sum = g.Sum(p => p.t1.QTY*p.t2.FLG01 + p.t1.QTY*p.t2.FLG04)};
我希望能够很好地将LINQ转换为SQL,因为我仅在对象上进行过尝试。