如何使用Lambda表达式编写此linq查询
public List<Employee> GetList()
{
return (from c in DALContext.MST
select new Employee(ID=c.CD, Name=c.NAME)).ToList();
}
答案 0 :(得分:5)
试试这个:
public List<Employee> GetList()
{
return DALContext.MST.Select(c => new Employee { ID = c.CD, Name = c.NAME }).ToList();
}