0

根据这个查询,我得到所有具有相同 id 的记录,但我只想要一次该记录

var query = (from c in CompObj.EmpInfoes
                     join d in CompObj.Leaves on c.EmpID equals d.ProjectManagerID
                     where c.RoleID == 4 || c.RoleID == 2
                     select new { c.EmpName, c.EmpID });
4

2 回答 2

4
var query = (from c in CompObj.EmpInfoes
             join d in CompObj.Leaves on c.EmpID equals d.ProjectManagerID
             where c.RoleID == 4 || c.RoleID == 2
             select new { c.EmpName, c.EmpID })
    .Distinct();

或者你还需要什么?

于 2013-06-05T06:29:21.363 回答
2

只需在末尾添加 .Distinct() 即可。

于 2013-06-05T06:30:54.233 回答