如何在linq中转换子查询?我的疑问是:
select *
from Product
where ID in
(
select distinct(sku.ProductId)
from SiteProducts sp
inner join ProductSKU sku on sp.ProductId = sku.Id
where sp.siteid = 2
)
答案 0 :(得分:2)
from p in db.Product
where (from sp in db.SiteProducts
join sku in db.ProductSKU on sp.ProductId equals sku.Id
where sp.siteid == 2
select sku.ProductId).Distinct().Contains(p.ID)
select p