2014-03-25 35 views
2
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如何顯示所有員工除了使用Linq?

+1

...'在哪裏u.Id!= CurrentUser.Id' ... – Jehof

+0

你是什麼意思是當前用戶ID? –

+2

爲什麼要爲平等比較創建匿名類型? –

回答

2
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, 
          }; 
0

使用where子句中的LINQ to濾除/列表

相關問題