var q = from f in first
join m in model on f.Id equals m.fID
where m.year == 2012
group new { f, m } by 1 into g
select new
{
credit1 = g.Sum(x => x.f.Acres * x.m.credit1),
credit2 = g.Sum(x => x.f.Acres * x.m.credit2),
credit3 = g.Sum(x => x.f.Acres * x.m.credit3)
};
var q = from f in first
join m in model on f.Id equals m.fID
where m.year >= 2014 && m.year <= 2020
group new { f, m } by m.year into g
select new
{
year = g.Key,
credit1 = g.Sum(x => x.f.Acres * x.m.credit1),
credit2 = g.Sum(x => x.f.Acres * x.m.credit2),
credit3 = g.Sum(x => x.f.Acres * x.m.credit3)
};