开发者

How to write this linq query using Lambda expression

开发者 https://www.devze.com 2023-02-17 18:29 出处:网络
How to write this linq query using Lambda expression public List开发者_Python百科<Employee> GetList()

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();
}
0

精彩评论

暂无评论...
验证码 换一张
取 消