How to write this linq query using Lambda expression
public List开发者_Python百科<Employee> GetList()
{
return (from c in DALContext.MST
select new Employee(ID=c.CD, Name=c.NAME)).ToList();
}
Try this:
public List<Employee> GetList()
{
return DALContext.MST.Select(c => new Employee { ID = c.CD, Name = c.NAME }).ToList();
}
精彩评论