且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在子查询上使用DISTINCT删除实体框架中的重复项

更新时间:2022-03-24 23:11:02

我认为您在这里不需要Distinct,而需要Exists(或在Linq中称为Any)

I dont think you need a Distinct here but a Exists (or Any as it is called in Linq)

尝试一下:

    var q = (from p in context.Practitioners
            where context.ProviderNetworks.Any(pn => pn.ProviderId == p.ProviderId && notNetworkIds.Contains(pn.Network))
            orderby p.UpdateDate descending
            select p).Skip(PageSize * (pageOffset ?? 0)).Take(PageSize).ToList();