1
這是我簡單的查詢轉換SQL語句到LINQ
Select id from employee where id in
(select employeeid from employeecenter where CenterCodeId in
(select CenterCodeId from employeecenter where employeeid=40))
我們怎樣才能acheive上述使用LINQ
//Gets all the centerCodeIds allotted to an employee
Session["LoggedUserId"] = 40;
List<int> _centerCodeIds = _cmn.GetCenterEmpwise(Convert.ToInt32(Session["LoggedUserId"]))
.Select(x => x.Id).ToList();
//Get all employees having the above centercodids
List<int> _employeeIds = _db.EmployeeCenters
.Where(x => _centerCodeIds.Any(cc => x.Id == cc))
.Select(x => x.Employee.Id).ToList();
@teovankot my bad;) –