Linq query from 3 tables using Joiner table
I have 3 tables, Customer, Surfboards, and CustomerSurfboards. CustomerSurfboards is the Joiner table.
Customer 开发者_StackOverflow社区 CustomerSurfBoards Surfboards
---------- ------------------- ------------
CustomerID CustomerSurfboardID SurfBoardID
IsActive CustomerID
SurfboardID
I want to select all surfboards where the customer IsActive = true
And I need to do this in Linq using C#
var query = from sb in db.Surfboards
join csb in db.CustomerSurfBoards on sb.SurfBoardID equals csb.SurfBoardID
join c in db.Customers on csb.CustomerID equals c.CustomerID
where c.IsActive
select sb;
精彩评论