DbSet.Include statement for ef7 accepting a string of string

EF6 has an overload of DbSet.Include, which takes a string parameter representing a list of related objects separated by periods to return in the query results. It is useful for high-load objects in a multi-level graph of objects. For instance:

var order = await _dbContext.Orders .Include(o => o.Customer) .Include("OrderDetails.Product") // dot-delimited path .SingleOrDefaultAsync(o => o.OrderId == id); 

This will return both related order details and populate the Product property of each part by creating an SQL statement that joins the OrderDetail and Product tables.

I am looking for a way to do this using EF7, but I do not see the DbSet.Include overload that takes a string path parameter. Does EF7 provide a way to achieve the same result as the EF6 API?

PS. I just noticed that issue # 1151 is open, and it looks like it can solve my question.

+6
source share
1 answer

You are correct that # 1151 is following this scenario. There are also some design notes that summarize the API that will be available in EF7 - https://github.com/aspnet/EntityFramework/wiki/Design-Meeting-Notes:-January-8,-2015 .

+8
source

Source: https://habr.com/ru/post/980116/


All Articles