Home > Back-end >  how to select a specific column using IQueryable<>?
how to select a specific column using IQueryable<>?

Time:12-15

I want to select only EmployeeNumber from Employee table how can I do that? Here is my code

IQueryable<Employee> employees = from employeess in db.Employees
                                             select employeess;

I know I can do

var employees = from employeess in db.Employees
                select employeess.EmployeeNumber;

but I want to use IQueryable any suggestions, please? thank you.

CodePudding user response:

Do you mean something like this:

IQueryable<int> employeeNumbers = db.Employees.Select(e => e.EmployeeNumber);
  • Related