diff --git a/test/Microsoft.EntityFrameworkCore.FunctionalTests/QueryTestBase.cs b/test/Microsoft.EntityFrameworkCore.FunctionalTests/QueryTestBase.cs index 08143352741..22b2723d3f0 100644 --- a/test/Microsoft.EntityFrameworkCore.FunctionalTests/QueryTestBase.cs +++ b/test/Microsoft.EntityFrameworkCore.FunctionalTests/QueryTestBase.cs @@ -59,10 +59,10 @@ public virtual void Queryable_reprojection() AssertQuery( cs => cs.Where(c => c.IsLondon) .Select(c => new Customer - { - CustomerID = "Foo", - City = c.City - })); + { + CustomerID = "Foo", + City = c.City + })); } [ConditionalFact] @@ -335,6 +335,19 @@ public virtual void Any_nested3() && c.City != "London")); } + [ConditionalFact] + public virtual void Any_with_multiple_conditions_still_uses_exists() + { + using (var context = CreateContext()) + { + var query = context.Customers + .Where(c => c.City == "London" && c.Orders.Any(o => o.EmployeeID == 1)) + .ToList(); + + Assert.Equal(4, query.Count); + } + } + [ConditionalFact] public virtual void All_top_level() { @@ -1244,7 +1257,7 @@ public virtual void Where_select_many_and() AssertQuery((cs, es) => from c in cs from e in es - // ReSharper disable ArrangeRedundantParentheses + // ReSharper disable ArrangeRedundantParentheses where (c.City == "London" && c.Country == "UK") && (e.City == "London" && e.Country == "UK") select new { c, e }); @@ -4820,7 +4833,7 @@ public virtual void Select_Where_Subquery_Equality() { var orders = (from o in context.Orders.Take(2) - // ReSharper disable once UseMethodAny.0 + // ReSharper disable once UseMethodAny.0 where (from od in context.OrderDetails.Take(2) where (from c in context.Set() where c.CustomerID == o.CustomerID diff --git a/test/Microsoft.EntityFrameworkCore.SqlServer.FunctionalTests/QuerySqlServerTest.cs b/test/Microsoft.EntityFrameworkCore.SqlServer.FunctionalTests/QuerySqlServerTest.cs index bb7afabc504..e01d907eb56 100644 --- a/test/Microsoft.EntityFrameworkCore.SqlServer.FunctionalTests/QuerySqlServerTest.cs +++ b/test/Microsoft.EntityFrameworkCore.SqlServer.FunctionalTests/QuerySqlServerTest.cs @@ -1360,6 +1360,20 @@ FROM [Orders] AS [o] Sql); } + public override void Any_with_multiple_conditions_still_uses_exists() + { + base.Any_with_multiple_conditions_still_uses_exists(); + + Assert.Equal( + @"SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] +FROM [Customers] AS [c] +WHERE ([c].[City] = N'London') AND EXISTS ( + SELECT 1 + FROM [Orders] AS [o] + WHERE ([o].[EmployeeID] = 1) AND ([c].[CustomerID] = [o].[CustomerID]))", + Sql); + } + public override void All_top_level() { base.All_top_level();