I call a GetData call which returned a IQueryable object. I used the following LINQ SelectMany to filter out and selected the fields which I need to
return a List<MyDataType> and I get the following error
Cannot implicitly convert type System.Collections.Generic.List<AnonymousType#1> to System.Collection.Generic.List<MyDataType>
Here is my code
List<CASES> caseList = cs.GetData(foiaNumber).ToList();
Dictionary<int, string> NameDict =
caseList.ToDictionary(cases => cases.UID, cases => cases.NAME);
List<MyDataType> bindingGrdList =
caseList.SelectMany(x => x.ListObject)
.Select(n =>
new {
SUBMITTER_NAME = NameDict[n.UID],
NUMBER = n.UID,
DATE_SENT = n.DATE_SENT,
DATE_DUE = n.DATE_DUE,
FINAL_DETERMINATION = n.FINAL_DETERMINATION
}).ToList();
How do I fix the AnonymousType error? thanks.
Replace
with