我有下一个代码:
var object =
(from result in ListOfINFO
group result by result.Name into grp
orderby grp.Key
select new
{
Name = grp.Key,
KM=grp.Sum(s=>s.KM),
Gasoline=grp.Where(w => w.Gasoline != "NaN").Sum(s => Convert.ToDouble(s.Gasoline)),
//Use=KM/Gasoline,//<=Something like that I want
}).ToList();
我想用以前的变量“KM”和“汽油”计算“使用”不重复所有操作,但我不能使用它们。我不知道是否有办法做到这一点。