I am trying to convert anonymous types to list but i am getting invocation errors like below.
An unhandled exception of type 'System.Reflection.TargetInvocationException' occurred in mscorlib.dll
var all = from a in Fcticuclist
join b in crlist on a.Ref_CID equals b.C_ID
select new { b.MU_Identifier, a.Status,a.ID };
foreach (var item in all)
{
castapprove.Add(new muapprovelist { Id = item.ID, MU_Identifier = item.MU_Identifier, Status = item.Status });
}
so here "all" is anonymous type and castapprove is a list and muapprovelist is a class and they are declared in the same view model. Any pointers where i am doing it wrong ?
castapprovedeclared? what kind of list is it? are you perhaps usingdynamic? My guess here is that you havedynamic castapprove = ...in which case... yeah, I wouldn't expect it to work.TargetInvocationExceptionnormally has anInnerExceptionthat explains what really went wrong (and where). Please post that information, too. Ismuapprovelistthe correct type for elements in that list (because it sounds like a list itself)?new { b.MU_Identifier, a.Status,a.ID }benew{MU_Identifier = b.MU_Identifier, Status = aStatus , ID = a.Status,a.ID }?MU_Identifier,StatusandIDin this case).