我是Linq的新手,我正在尝试使用northwind数据库编写一个查询,该查询应该返回在同一类别中有两个或更多产品的所有供应商。
var test1 =
(from p in Products
join pi in Products on p.CategoryID equals pi.CategoryID
join pf in Products on p.SupplierID equals pf.SupplierID
where p.ProductID != pi.ProductID
select new
{p.ProductName, p.CategoryID, p.SupplierID}).ToList().Distinct();
test1.Dump();这是我最后一次尝试,但没有成功。我有点听天由命了,因为我已经尝试了几个小时了,但它仍然没有做到它应该做的事情。也许我完全搞错了?
我的方法是必须有两个或更多的清单具有相同的SupplierID和CategoryID,但不同的ProductID,但我还没有找到解决方案。
https://stackoverflow.com/questions/41344271
复制相似问题