c# - Casting Object/Dynamic to Anonymous Type -


i have ef query returns anonymous type of several joined tables. pass function dynamic. there way cast dynamic anonymous type of known anonymous type? if there way this, assume passing object better dynamic, correct?

... var appts = (from in dbc.tblappt join b in dbc.tblappttypes on a.type equals b.type select new {a, b}).tolist(); if (appts.any())     processappts(appts); }  void processappts(dynamic appts) {     var anontypeappts = appts (new {tblappt, tblappttypes}); // bit here } 

no. anonymous types are... anonymous. can't cast variable anonymous type, tried in code. , preferably shouldn't pass them around though other methods. should kept inside. , shouldn't use dynamic this.

i suggest create 'real' type can pass around method.


Comments