How can I convert this join to LINQ syntax?
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 Produc开发者_运维技巧tTool 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=>, ...)
If you have foreign keys setup correctly, the entity framework should pick that relationship up and you should be able to simply do:
var tools = from p in products where p.X == 14 select p.Tool;
精彩评论