DbSet.Include operator for ef7 accepting string path

entity-framework-core

Question

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.

Accepted Answer

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.



Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Is this KB legal? Yes, learn why
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Is this KB legal? Yes, learn why