小编Ank*_*odi的帖子

如何使用 lambda 表达式将 DataTable 记录放入列表中?

在给定的代码中,我编写了 lambda 表达式,但它显示了一个错误 -- 无法将 lambda 表达式转换为类型“string”,因为它不是委托类型。

        EmployeeDataOperation emp = new EmployeeDataOperation(); //Class to perform CRUD operation.

        List<EmployeeProp> data = new List<EmployeeProp>();

        dt = emp.getEmployeeData();//return datatable with records.

        //I want to use lambda expression to use Datatable data as a list
        data = (from a in dt
                select new EmployeeProp { Name = a.Name, Email = a.Email }).ToList();
        //error near select

        return View(data);
Run Code Online (Sandbox Code Playgroud)

c# model-view-controller asp.net-mvc

1
推荐指数
1
解决办法
9937
查看次数

标签 统计

asp.net-mvc ×1

c# ×1

model-view-controller ×1