Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Collection_navigation_equal_to_null_for_subquery fails after merging from release/6.0 #27356

Closed
ajcvickers opened this issue Feb 3, 2022 · 0 comments
Assignees
Labels
area-query closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. Servicing-approved type-bug
Milestone

Comments

@ajcvickers
Copy link
Member

All providers.

[ConditionalTheory]
[MemberData(nameof(IsAsyncData))]
public virtual Task Collection_navigation_equal_to_null_for_subquery(bool async)
    => AssertQuery(
        async,
        ss => ss.Set<Customer>().Where(c => c.Orders.OrderBy(o => o.OrderID).FirstOrDefault().OrderDetails == null),
        ss => ss.Set<Customer>().Where(c => c.Orders.OrderBy(o => o.OrderID).FirstOrDefault() == null),
        entryCount: 2);
The LINQ expression 'DbSet<Customer>()
    .Where(c => DbSet<Order>()
        .Where(o => EF.Property<string>(c, "CustomerID") != null && object.Equals(
            objA: EF.Property<string>(c, "CustomerID"), 
            objB: EF.Property<string>(o, "CustomerID")))
        .OrderBy(o => o.OrderID)
        .Select(o => MaterializeCollectionNavigation(
            Navigation: Order.OrderDetails,
            subquery: DbSet<OrderDetail>()
                .Where(o0 => EF.Property<int?>(o, "OrderID") != null && object.Equals(
                    objA: (object)EF.Property<int?>(o, "OrderID"), 
                    objB: (object)EF.Property<int?>(o0, "OrderID")))))
        .FirstOrDefault() == null)' could not be translated. Either rewrite the query in a form that can be translated, or switch to client evaluation explicitly by inserting a call to 'AsEnumerable', 'AsAsyncEnumerable', 'ToList', or 'ToListAsync'. See https://go.microsoft.com/fwlink/?linkid=2101038 for more information.
maumar added a commit that referenced this issue Feb 11, 2022
…s after merging from release/6.0

Improvement on the previous patch fix (#26744). We were not taking into the account scenario where collection projected from FirstOrDefault was compared to null. Collection can only be null if the parent entity is null, so we can safely apply the same optimization we do for anonymous types and required entities.

Fixes #27356
@maumar maumar added the closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. label Feb 11, 2022
maumar added a commit that referenced this issue Feb 11, 2022
…s after merging from release/6.0

Improvement on the previous patch fix (#26744). We were not taking into the account scenario where collection projected from FirstOrDefault was compared to null. Collection can only be null if the parent entity is null, so we can safely apply the same optimization we do for anonymous types and required entities.

Fixes #27356
@AndriySvyryd AndriySvyryd added this to the 6.0.4 milestone Feb 15, 2022
dougbu pushed a commit that referenced this issue Mar 2, 2022
…s after merging from release/6.0 (#27429)

Improvement on the previous patch fix (#26744). We were not taking into the account scenario where collection projected from FirstOrDefault was compared to null. Collection can only be null if the parent entity is null, so we can safely apply the same optimization we do for anonymous types and required entities.

Fixes #27356
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-query closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. Servicing-approved type-bug
Projects
None yet
Development

No branches or pull requests

4 participants