我的SQL查询需要等效的LINQ查询
问题描述:
SELECT * FROM Tbl_Vulpith_Registration
WHERE MemId NOT IN (select MemId from Tbl_PublicLink);
答
在下面尝试以下代码段:
Try this snippet below:
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));