如何显示所有的员工除了一个使用Linq


IEnumerable<ViewEmployees> us = from u in db.Users
                          join s in db.Designations
                          on new { id = u.DesignationID } equals new { id = s.DesignationID }
                          select new ViewEmployees
                          {
                           EmployeeName = u.Name,
                           EmployeeID = u.Id,
                           EmployeeCode = u.UserName,
                           Designation = u.DesignationID,
                           DesignationName = s.DesignationName,
                          };

它显示了所有的记录,但我想看到所有的记录,除了1..

使用linq中的where子句过滤掉列表

IEnumerable<ViewEmployees> us = from u in db.Users
                          join s in db.Designations
                          on new { id = u.DesignationID } equals new { id = 
                          s.DesignationID }
                          Where u.Id != LoggedInUserId
                          select new ViewEmployees
                          {
                           EmployeeName = u.Name,
                           EmployeeID = u.Id,
                           EmployeeCode = u.UserName,
                           Designation = u.DesignationID,
                           DesignationName = s.DesignationName,
                          };

相关内容

  • 没有找到相关文章

最新更新