Hi I\'m new to programming, could you please help me with this one:
I\'am getting an error in \"To.List()\" Error 1 Cannot implicitly convert type \'System.Co
You are basically trying to assign an anonymous type
new { d.Key.month, d.Key.year, count = d.Count() }
to your object. Instead of select new { ... }, just select new IncByYrMonthModel() { ... } to populate your object.
You should just change this
select new { d.Key.month, d.Key.year, count = d.Count() }
to this
select new IncByYrMonthModel { Month = d.Key.month, Year = d.Key.year, Total = d.Count() }
The problem in the first case is that you have a sequence of object of an anonymous type, which you try to convert them to a list of IncByYrMonthModel
, which is impossible.