开发者

Linq query from 3 tables using Joiner table

开发者 https://www.devze.com 2022-12-10 11:51 出处:网络
I have 3 tables, Customer, Surfboards, and CustomerSurfboards.CustomerSurfboards is the 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;
0

精彩评论

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