Skip to content

Commit

Permalink
Don't run Select_nested_projection without MARS
Browse files Browse the repository at this point in the history
Fixes #17117
  • Loading branch information
AndriySvyryd committed Aug 13, 2019
1 parent ab44b00 commit 1e4d2e5
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -257,12 +257,6 @@ FROM root c
WHERE ((c[""Discriminator""] = ""Customer"") AND (c[""City""] = ""London""))");
}

[ConditionalTheory(Skip = "Issue #16143")]
public override void Select_nested_projection()
{
base.Select_nested_projection();
}

public override async Task Select_nested_collection(bool isAsync)
{
await base.Select_nested_collection(isAsync);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -408,32 +408,6 @@ from c in cs
select c.City);
}

[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)
{
Assert.Same(customer.Customer, customer.CustomerAgain);
}
}
}

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

[ConditionalTheory(Skip = "Issue#16314")]
[MemberData(nameof(IsAsyncData))]
public virtual Task Select_nested_collection(bool isAsync)
Expand Down
61 changes: 61 additions & 0 deletions test/EFCore.SqlServer.FunctionalTests/Query/QueryBugsTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6071,6 +6071,67 @@ public class Repo15518

#endregion

#region Bug8864

[ConditionalFact]
public virtual void Select_nested_projection()
{
using (CreateDatabase8864())
{
using (var context = new MyContext8864(_options))
{
var customers = context.Customers
.Select(c => new
{
Customer = c,
CustomerAgain = Get(context, c.Id)
})
.ToList();

Assert.Equal(2, customers.Count);

foreach (var customer in customers)
{
Assert.Same(customer.Customer, customer.CustomerAgain);
}
}
}
}

private static Customer8864 Get(MyContext8864 context, int id)
=> context.Customers.Single(c => c.Id == id);

private SqlServerTestStore CreateDatabase8864()
=> CreateTestStore(
() => new MyContext8864(_options),
context =>
{
context.AddRange(
new Customer8864 { Name = "Alan" },
new Customer8864 { Name = "Elon" });

context.SaveChanges();

ClearLog();
});

public class MyContext8864 : DbContext
{
public DbSet<Customer8864> Customers { get; set; }

public MyContext8864(DbContextOptions options) : base(options)
{
}
}

public class Customer8864
{
public int Id { get; set; }
public string Name { get; set; }
}

#endregion

private DbContextOptions _options;

private SqlServerTestStore CreateTestStore<TContext>(
Expand Down

0 comments on commit 1e4d2e5

Please sign in to comment.