How to write this linq query using Lambda expression
public List<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();
}
new Employee(ID = c.CD, Name = c.NAME) should be new Employee{ID = c.CD, Name = c.NAME}new Employee(ID: c.CD, Name: c.NAME)