显示不在表中的所有AD组成员
本文关键字:AD 组成员 显示 | 更新日期: 2023-09-27 17:51:16
如何将下面的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;