I want to retrieve all tools used by products with X = 14
, how can I convert this select to LINQ?
SELECT DISTINCT t.* FROM Product p
INNER JOIN ProductTool pt ON pt.Product_ID = p.ID
INNER JOIN Tool t ON t.ID = pt.Tools_ID
WHERE p.X = 14
Is GroupJoin
what I need or what?
tools.GroupJoin(products, t=>, p=>, ...)
products.GroupJoin(tools, p=>, t=>, ...)
如果正确设置了外键,则实体框架应选择该关系,并且您可以简单地执行以下操作:
var tools = from p in products where pX == 14 select p.Tool;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.