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 ..当前用户ID
之外的所有记录答案 0 :(得分:0)
使用linq中的where子句来过滤/列表
答案 1 :(得分:0)
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,
};