【发布时间】:2023-03-15 17:50:02
【问题描述】:
这是我的示例查询
Select id from employee where id in
(select employeeid from employeecenter where CenterCodeId in
(select CenterCodeId from employeecenter where employeeid=40))
我们如何使用 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 我的错 ;)
标签: entity-framework linq