I have the structure below:
- Product Category
- Product (with one Product Category)
- ProductComplementCategory (Product has many ProductComplementCategory)
- ComplementCategory (ProductComplementCategory has one ComplementCategory)
- ComplementCategoryComplements (ComplementCategory has many ComplementCategoryComplements)
- Complement (ComplementCategoryComplements has one Complement)
All tables has the property "Active" and I need to select all tables with join but filtering active = 1 in tables Product Category, Product, ComplementCategory and Complement
Query in SQL:
SELECT
pc.*,
p.*,
cc.*,
c.*
FROM
ProductCategory pc
JOIN Product p ON pc.[ Uid ] = p.ProductCategoryId
JOIN ProductComplementCategory pcc ON p.[ Uid ] = pcc.ProductID
JOIN ComplementCategory cc ON pcc.ComplementCategoryID = cc.[ Uid ]
JOIN ComplementCategoryComplements ccc ON cc.[ Uid ] = ccc.ComplementCategoryID
JOIN Complement c ON ccc.ComplementID = c.[ Uid ]
WHERE
pc.Active = 1
AND p.Active = 1
AND cc.Active = 1
AND c.Active = 1
I need to do this query in EF Core!
i hope this would help you