You can get entities from multipletables with a single LINQ call using the
Include operator. You can load related entities from another table into the current entity using the include operator.
The syntax for Include operator is as follows:
from entity in source
include relatedEntity
where entity is the name of the entity loading the related entitiy and
relatedEntity is the name of the related entity.
For example, the following code retrieves all the customers and their orders in a single LINQ call:
from customer in Customers
include customer.Orders
This code will first load all the customers from the Customers table. Then load all the orders for each customer from the
Orders table.
You can also load multiple related entities in a single LINQ call using the include operator. For example, the following code gets all the customers, their orders, and the products that they ordered in a single LINQ call:
from customer in Customers
include customer.Orders
include customer.Orders.Products
This code will first loads all the customers from the Customers table. Then, load all the orders of each customer from the
Orders table. Finally, all the products ordered by each customer are loaded from the Products table.
Markdown for AI
A clean, structured version of this page for AI assistants and LLMs.
We use cookies to ensure you have the best browsing experience on our website. By using our site, you
acknowledge that you have read and understood our
Cookie Policy &
Privacy Policy.
You can get entities from multiple tables with a single LINQ call using the
Includeoperator. You can load related entities from another table into the current entity using the include operator.The syntax for
Includeoperator is as follows:where
entityis the name of the entity loading the related entitiy andrelatedEntityis the name of the related entity.For example, the following code retrieves all the customers and their orders in a single LINQ call:
This code will first load all the customers from the
Customerstable. Then load all the orders for each customer from theOrderstable.You can also load multiple related entities in a single LINQ call using the include operator. For example, the following code gets all the customers, their orders, and the products that they ordered in a single LINQ call:
This code will first loads all the customers from the
Customerstable. Then, load all the orders of each customer from theOrderstable. Finally, all the products ordered by each customer are loaded from the Products table.