Env:
EntityFrameworkCore.Projectables 6.0.6, EF Core 10.0.3, Npgsql.EntityFrameworkCore.PostgreSQL 10.0.0, .NET 10
Given the following:
public class Root
{
public Guid Id { get; set; }
public int Units { get; set; }
public List<Leaf> Leaves { get; set; } = [];
[Projectable(UseMemberBody = nameof(ComputedExpression))]
[NotMapped]
public int Computed { get; set; }
private static Expression<Func<Root, int>> ComputedExpression => x => x.Units * 2;
}
The following queries result in:
db.Roots.AsNoTracking().ToQueryString(); // LEFT JOIN "Leaves" <-- unexpected
db.Roots.ToQueryString(); // no join <-- expected
If the above entity had 13 navigation properties (as was the case in our code), there would be 13 left joins on them.
The fix is to either Remove AsNoTracking() or make Computed get-only.
Env:
Given the following:
The following queries result in:
If the above entity had 13 navigation properties (as was the case in our code), there would be 13 left joins on them.
The fix is to either Remove
AsNoTracking()or makeComputedget-only.