-1

我将如何将以下 sql 查询转换为 LINQ

select *
from groupprincipal.members 
where displayname not in (select adusername 
                          from employees)

我想列出 Active Directory 组中不在员工表中的所有成员

我试过了

var notLoggedIn = from groupMembers in groupPrincipal.Members
                          from loggedIn in employeeRepository.All
                          where groupMembers.DisplayName != loggedIn.ActiveDirectoryName
                          select groupMembers;

但你会知道它没有用。

4

2 回答 2

2
var notLoggedIn = from groupMembers in groupPrincipal.Members
                  where !employeeRepository.Select(p=> p.adUserName).Contains(groupMembers.DisplayName)
                  select groupMembers;
于 2013-01-11T14:12:17.567 回答
1

我相信这应该这样做:

var notLoggedIn = 
from groupMembers in groupPrincipal.Members
where !(from loggedIn in employeeRepository.All
        select loggedIn.ActiveDirectoryName).Contains(groupMembers.DisplayName)
select notLoggedIn;
于 2013-01-11T14:09:32.853 回答