Explicit loading related data for a non-tracked entity

Viewed 58

I've a non tracked entity, a want do resolve some navigations of it. So no EntityEntry will exist in the change tracker. What is the best way to query through some related tables.

That's my code looking, but currently not working due to the missing Entry in change tracker:

context.ParentTable.AsNoTracking().First();
context.Entry(ParentTable).Collection(p => p.Children).Load();

So far I understand why this won't work.

My workaround is very simple, but it creates a lot of overhead:

var children = context.ParentTable.AsNoTracking().Include(p => p.Children);

Do I really have to build a new query with all Includes to get the related records or is there a better way?

0 Answers
Related