SELECT * FROM Tbl_Vulpith_Registration
WHERE MemId NOT IN (select MemId from Tbl_PublicLink);
答案 0 :(得分:0)
请尝试以下代码段:
var query = from c in dc.Tbl_Vulpith_Registration
where !(from o in dc.Tbl_PublicLink
select o.MemId )
.Contains(c.MemId )
select c;
或使用扩展方法:
var resultList= Tbl_Vulpith_Registration.Where(p => !Tbl_PublicLink.Any(p2 => p2.MemId == p.MemId));
答案 1 :(得分:0)
将SQL转换为LINQ查询理解:
IN
翻译为.Contains()
,将NOT IN
翻译为!...Contains()
因此您的SQL查询转换为:
var ExcludeMemIds = from pl in Tbl_PublicLink select pl.MemId;
var ans = from vr in Tbl_Vulpith_Registration
where !ExcludeMemIds.Contains(vr.MemId)
select vr;