var list = List1.Join(
List2,
l1 => new { l1.Cityid },
l2 => new { l2.Cityid },
(item1, item2) => new
{
Report_date = item1.Rdate,
Cityname = item2.Cityname,
Th = item1.Th,
Yh=item1.Yh,
Eh= item1.Eh,
}) //2列表left jion
.GroupBy(p => new { p.Report_date, p.Cityname })
.Select(g => new
{
Cityname = g.Key.Cityname,
Report_date = g.Key.Rdate,
DH = g.Sum(t => t.Th) + g.Sum(t => t.Yh) + g.Sum(t=>t.Eh)
}).ToList();//分组计算
转载于:https://www.cnblogs.com/TTonly/p/11608456.html