What I am attempting to accomplish here is return 1 car per year for ten years.
what I am getting though is 10 cars that are all 2013 cars.
This should sort by year 2013 2012 2011 etc.. It should be the car with the most recalls for that given year.
public static IEnumerable<MakeModel> mostrecalledmodelbyYear
{
get
{
var groups = from t in DBCacheHelper.recallslist
where t.YEARTXT != "9999"
group t by new { t.YEARTXT, t.MODELTXT, t.MAKETXT } into g
select new MakeModel() { MODELTXT = g.Key.MODELTXT, MAKETXT = g.Key.MAKETXT, Frequency = g.Count(),YEARTXT = Convert.ToInt32(g.Key.YEARTXT) };
return groups.OrderByDescending(g => g.YEARTXT).Take(10);
}
}
Should be something like that