显示不在表中的所有AD组成员



如何将下面的sql查询转换为LINQ

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

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

I tried

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

var notLoggedIn = from groupMembers in groupPrincipal.Members
                  where !employeeRepository.Select(p=> p.adUserName).Contains(groupMembers.DisplayName)
                  select groupMembers;

我相信这应该可以做到:

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

相关内容

  • 没有找到相关文章

最新更新