我有这个SQL语句可以正常工作。我试图将此转换为VB Linq to SQL语句,没有任何运气。我被困在这里有人可以帮帮我吗?
SELECT P.*
FROM Product AS P
WHERE EXISTS (
SELECT productid
FROM Product_Promo AS PP
WHERE P.productid = PP.productid
AND P.Someid = 1003
AND PP.ADate > getdate()
GROUP BY productid
HAVING COUNT(*) > 1
);
我的VB.Net尝试:
From p In Products
Where (From pp In Product_Promo
Where pp.ADate > DateTime.Now
Select pp.productid
Group By productid
Into Group
Where Group.Count > 1)
.Contains(p.ProductID)
Select p
Where p.Someid = 1003
知道了!
Products.Where(Function(p) (p.Product_Promo.AsEnumerable().Count(Function(pp) ((p.SomeID = 1003) AndAlso (pp.ADate> DateTime.Now))) > 1))
感谢您的回答......