One example of when this may happen is if an opaque method that takes an entity as an argument is invoked in the Where clause, e.g.:
var query = context.People
.Include(p => p.Addresses)
.Where(p => p.Name.StartsWith(name) && IsCustomer(p));
Given the current behavior, the p passed to IsCustomer won't be tracked, and the Addresses navigation property won't be populated.
If IsCustomer(p) returns false, then that person entity won't end in the query results. For a tracked query that means that the instance will be discarded and not tracked. Moreover, for specific providers (e.g. Cosmos DB), even if IsCustomer(p) returns true, p could be a different object instance from the one that will be included in query results.
Hence the proposal is to make this situation trigger a warning.
One example of when this may happen is if an opaque method that takes an entity as an argument is invoked in the Where clause, e.g.:
Given the current behavior, the
ppassed toIsCustomerwon't be tracked, and theAddressesnavigation property won't be populated.If
IsCustomer(p)returns false, then that person entity won't end in the query results. For a tracked query that means that the instance will be discarded and not tracked. Moreover, for specific providers (e.g. Cosmos DB), even ifIsCustomer(p)returns true,pcould be a different object instance from the one that will be included in query results.Hence the proposal is to make this situation trigger a warning.