Unable to type cast <AnonymousType#1> to <WindowsFormsApplication1.Attributes> [ C#3.0 ]
- by Newbie
I have
List<Attributes> la = new List<Attributes>();
la = (from t in result
let t1 = t.AttributeCollection
from t2 in t1
where t2.AttributeCode.Equals(attributeType)
let t3 = t2.TimeSeriesData
from k in t3.ToList()
where k.Key.Equals(startDate) && k.Key.Equals(endDate)
select new
{
AttributeCode = attributeType,
TimeSeriesData = fn(k.Key, k.Value.ToString())
}).ToList<Attributes>();
I am getting the error:
'System.Collections.Generic.IEnumerable<AnonymousType#1>' does not contain a definition for 'ToList' and the best extension method overload 'System.Linq.Enumerable.ToList<TSource>(System.Collections.Generic.IEnumerable<TSource>)' has some invalid arguments
I understood tye error meaning but how to type cast it. I have used var and then iterating over it got the result. But without that any other way by which I can do it?
Using C# 3.0
Thanks