面对着看起来简单的问题
var SummaryCollection = (from n in ...long criteria with group by clause)
into g select new
{ MonthYear = g.Key,
Amount = g.Sum(p=>p.Amount)}).OrderBy(p=>p.MonthYear);
}
我现在得到的数据 看起来像这个样子
Jan2009 $100
Feb2009 $134
... and so on
最后,我终于
decimal avgAmount = (from x in SummaryCollection select x.Amount).Average();
I now need to get the average of last N months where N is input in a textbox by the user. Please advise how to get avg of last N from an ordered collection using Linq. thank you