将SelectList转换为List

时间:2014-05-15 23:11:58

标签: c# asp.net-mvc-3

如何将SelectList转换为List()?

代码:

Session["Employers"] = new SelectList(employers.DistinctBy(i => i.empId), "EmpId", "EmpName");

1 个答案:

答案 0 :(得分:1)

最后添加ToList()

Session["Employers"] = new SelectList(employers.DistinctBy(i => i.empId), "EmpId", "EmpName").ToList();