linq to entities - How to convert anynoymous type? -
i try convert anonymous type class don't.
my code in viewmodel :
<public list**<???>** poolcondition { get; set; } entities db = new entities(); public selectlistviewmodel() { string lang = sessionmanager.language; var poolcondition = (from ddlv in db.dropdownlistvalue ddlv_t in ddlv.dropdownlistvalue_translation ddlv_t.language.code == lang select new { ddlv.id, ddlv_t.traduction }).tolist(); poolcondition = poolcondition;
i've error width poolcondition=poolcondition, because poolcondition anonymous type. how cast list poolcondition??
thank you!
rather creating list of anonymous types, why not create list of objects? perhaps like:
var poolcondition = (from ddlv in db.dropdownlistvalue ddlv_t in ddlv.dropdownlistvalue_translation ddlv_t.language.code == lang //initialize object appropriately select new poolcondition { id = ddlv.id, traduction = ddlv_t.traduction }) .tolist();
Comments
Post a Comment