根据这个查询,我得到所有具有相同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 });
答案 0 :(得分: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();
或者你需要更多东西吗?
答案 1 :(得分:2)
最后添加.Distinct()。