Reputation: 97
I have 3 related Tables in MS SQL Server.
Table_Bid and Table_Stock are related to Table_Product with ProductId.
I want to fetch the Data like this query in Entity Framework Core
Select * from Table_Bid
left join Table_Product on Table_Bid.ProductId = Table_Product.Id
inner join Table_Stock on Table_Stock.ProductId = Table_Bid.ProductId
Using .Include and .ThenInclude i am unable to fetch the records, rather while using this query i am getting the records
My C# Code is :
List<TableBid> bid =
_context.TableBid
.Include(c => c.Product.TableStock)
.ToList();
Please guide me how to get data from all three table at once using Entity Framework Core.
Upvotes: 1
Views: 1588
Reputation: 11464
As @Daniel García Rubio noted, it is hard to answer your question with the small amount of information you provided in your question. Without knowing more though, it would seem like you are looking for the following:
List<TableBid> bid =
_context.TableBid
.Include(bid => bic.Product.TableStock)
.ThenInclude(stock => stock.Product)
.ToList();
Upvotes: 2