A query with inclusion returns a single result set, and the number of inclusions affects how a large set of data is transferred from the database server to the web server. Example:
Suppose we have an entity Customer (Id, Name, Address) and an entity Order (Id, CustomerId, Date) . Now we want to request a client with her orders:
var customer = context.Customers .Include("Orders") .SingleOrDefault(c => c.Id == 1);
The resulting dataset will have the following structure:
Id | Name | Address | OrderId | CustomerId | Date --------------------------------------------------- 1 | A | XYZ | 1 | 1 | 1.1. 1 | A | XYZ | 2 | 1 | 2.1.
This means that Cutomers data is repeated for each Order . Now let's expand the example with other objects - "OrderLine" (Id, OrderId, ProductId, Quantity) and Product (Id, Name) `. Now we want to request a client with her orders, orders and products:
var customer = context.Customers .Include("Orders.OrderLines.Product") .SingleOrDefault(c => c.Id == 1);
The resulting dataset will have the following structure:
Id | Name | Address | OrderId | CustomerId | Date | OrderLineId | LOrderId | LProductId | Quantity | ProductId | ProductName ------------------------------------------------------------------------------------------------------------------------------ 1 | A | XYZ | 1 | 1 | 1.1. | 1 | 1 | 1 | 5 | 1 | AA 1 | A | XYZ | 1 | 1 | 1.1. | 2 | 1 | 2 | 2 | 2 | BB 1 | A | XYZ | 2 | 1 | 2.1. | 3 | 2 | 1 | 4 | 1 | AA 1 | A | XYZ | 2 | 1 | 2.1. | 4 | 2 | 3 | 6 | 3 | CC
As you can see, the data becomes pretty much duplicated. The total number of each of them refers to the correct navigation ( Product in the example) will add new columns and each of them will include collections in the navigation property ( Orders and OrderLines in the example) will add new columns and duplicate the already created rows for each row in the included collection.
This means that your example can easily contain hundreds of columns and thousands of rows that require a lot of data to transfer. The right approach is to create performance tests, and if the result does not meet your expectations, you can change your query and load the navigation properties separately with your own queries or the LoadProperty method.
Example of individual queries:
var customer = context.Customers .Include("Orders") .SingleOrDefault(c => c.Id == 1); var orderLines = context.OrderLines .Include("Product") .Where(l => l.Order.Customer.Id == 1) .ToList();
LoadProperty example:
var customer = context.Customers .SingleOrDefault(c => c.Id == 1); context.LoadProperty(customer, c => c.Orders);
Also, you should always download only the data that you really need.
Edit: I just created an offer