开发者

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;

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜