Q:

Explicitly loading all navigation properties in a list of previously fetched objects in Entity Framework?

Suppose I have something like
 var remoteData = query.Where(s => <conditions here>).ToArray();

and every object in the array has a navigation property called Department.
Is there a way of explicitly loading all the Department properties in a single query to the SQL server.
Doing something like this results in numerous queries
remoteData.ForEach(rd =>
{
    rd.DepartmentReference.Load();
});

I know about Include but that is too slow. I want to load everything after the filtering takes place.

A:

No, if you want to get data faster, you should select releted entities in separate query like this:
var deps = dbContext.DepartmentReference.Where(o=>...).ToDictionary(o=>o.DataID);

Here you can join this query on your query not to repeat condition.
And then set values:
remoteData.ForEach(rd =>
{
    rd.DepartmentReference = deps[rd.ID];
});

