Linq使用Contains

时间:2013-09-18 06:21:41

标签: c# .net linq

我正在尝试从特定经理检索员工列表。我首先找到经理转移,然后找到这个转变的经理列表。第三个查询需要检索属于该经理列表的所有员工。我不知道什么是错的,但我没有得到任何结果。感谢您的帮助

   //Determine shift of current user
    int shiftId = (from s in db.webpages_UsersInRoles
                   where s.UserId == userId
                   select s.ShiftId).Single();
    var ManagerId = (from g in db.tblManager
                      where g.ShiftId == shiftId
                      select g.UserID).ToList();

var employees = (from e in db.tblEmployee
                 where ManagerId.Contains(e.ShiftId.Value)                            
                 select e).ToList();

1 个答案:

答案 0 :(得分:0)

您的上一个查询是针对e.ShiftId检查它应该针对e.EmployeeId

var employees = (from e in db.tblEmployee
                 where ManagerId.Contains(e.EmployeeId.Value)                            
                 select e).ToList();