Skip to content

Query: Nested and outer query results are tracked separately #8864

@AndriySvyryd

Description

@AndriySvyryd

This results in different instances returned for the same entity:

[ConditionalFact]
public virtual void Select_nested_projection()
{
    using (var context = CreateContext())
    {
        var customers = context.Customers
            .Where(c => c.CustomerID.StartsWith("A"))
            .Select(c => new
            {
                Customer = c,
                CustomerAgain = Get(context, c.CustomerID)
            })
            .ToList();

        Assert.Equal(4, customers.Count);
        foreach (var customer in customers)
        {
            // This fails
            Assert.Same(customer.Customer, customer.CustomerAgain);
        }
    }
}

private Customer Get(NorthwindContext context, string id)
    => context.Customers.Single(c => c.CustomerID == id);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions