EF6 has an overload of DbSet.Include which accepts a string parameter representing a dot-separated list of related objects to return in the query results. It is useful for eager-loading entities in a multi-level object graph. For example:
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 detail by generating a SQL statement that joins OrderDetail and Product tables.
I am looking a way to do this with EF7, but I don't see an overload of DbSet.Include which accepts a string path parameter. Does EF7 provide a way to achieve the same result as the EF6 API?
PS. I just noticed issue #1151 is open, and it looks like it may address my question.
You are correct that #1151 is tracking this scenario. There are also some design meeting notes that summarize the API that will be available in EF7 - https://github.com/aspnet/EntityFramework/wiki/Design-Meeting-Notes:-January-8,-2015.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With