I have 2 data objects. Employee and Manager
class Employee{
int EmpId;
int EmpName }
Class Manager{
int ManagerID; //is the empId of an employee who is Manager
}
I want a list of EmpName who is not a Manager using LINQ in a single statement.
I tried this:
var employeeIdsWhoAreNotManagers = EmployeeList.Select(x=>x.EmpId).Except(Managerlist.Select(x=>x.ManagerId));
but this returns me only EmpId. Then again i have to write one more linq to get the EmpName .
Update1:
empNamesList = EmployeeList.Where(x=>x.employeeIdsWhoAreNotManagers.Contains(x.empId)).Select(x=>x.empName);
How do I Combine into a single LINQ query which results me the EmpName list directly?