As you already mentioned, Include is only valid when the end result of a query consists of objects that must include Include -d navigation properties.
So, in this case, Include has the effect:
var list = _db.SampleEntity.Include(s => s.NavProp1).ToList();
The SQL query will contain a JOIN , and each SampleEntity will load NavProp1 .
In this case, it does not affect:
var list = _db.SampleEntity.Include(s => s.NavProp1) .Select(s => new { s }) .ToList();
The SQL query does not even contain a JOIN ; EF completely ignores Include .
If in the last query you want SampleEntity contain their NavProp1 , you can do:
var list = _db.SampleEntity .Select(s => new { s, s.NavProp1 }) .ToList();
Now the Entity Framework retrieves SampleEntity and NavProp1 entities from the database separately, but glues them together with the relationship correction process. As you can see, Include not required to happen.
However, if NavProp1 is a collection, you will notice that ...
var navprop1 = list.First().s.Navprop1;
... will still execute the query to retrieve NavProp1 by lazy loading. Why is this?
While fixing the relationship fills the properties of NavProp1 , it does not put them as downloaded. This only happens when Include loads properties. So now we have SampleEntity all having their own NavProp1 s, but you cannot access them without starting lazy loading. The only thing you can do to prevent this is
_db.Configuration.LazyLoadingEnabled = false; var navprop1 = list.First().s.Navprop1;
(or by preventing lazy loading by disabling proxy creation or not making NavProp1 virtual.)
Now you will get NavProp1 without a new request.
For reference navigation properties, this does not apply, lazy loading does not start when it is turned on.
In the Entity Framework, the situation has changed a lot in this area. At first (at the time of writing), lazy loading is not enabled, not to mention its inadvertent launch. But Include behavior is also different. Now a query like _db.SampleEntity.Include(s => s.NavProp1).Select(s => new { s }) will include NavProp1 in the final result. EF-core is smarter in finding "Includable" objects in the end result.