Efcore: Explicit Loading with Includes possible?

Created on 20 Feb 2017  路  1Comment  路  Source: dotnet/efcore

I am trying to migrate a project from EF 5 to EF Core 1.1 that makes heavily use of the lazy loading feature of the older EF project.

In several places, I have to load navigation properties of an object, which also need to load their navigation properties and so on.
So i wondered if it could be a possible feature (or maybe it is already possible) to use "Includes" in the explicit loading. Something like
dbcontext.Entry(entity).Collection('MyCollection').Load(new String[]{"Include1.NavProp", "Include""})

Edit: or is it maybe possible to load eg. a collection in a different place and tell the EF that this collection is a navigation property of a given entity? Something like dbcontext.Entry(entity).setLoaded("NavigationName", myCollection)

closed-question

Most helpful comment

You can get a LINQ query for the navigation, which then allows you to include etc.

```c#
dbcontext.Entry(blog).Collection('Posts').Query().Include(p => p.Tags).Load();

You can also tell EF that a property is loaded:

```c#
context.Entry(blog).Collection("Posts").IsLoaded = true;

>All comments

You can get a LINQ query for the navigation, which then allows you to include etc.

```c#
dbcontext.Entry(blog).Collection('Posts').Query().Include(p => p.Tags).Load();

You can also tell EF that a property is loaded:

```c#
context.Entry(blog).Collection("Posts").IsLoaded = true;
Was this page helpful?
0 / 5 - 0 ratings