From 0a7fd2581af38093ac43efa2735847dbd8eb5fea Mon Sep 17 00:00:00 2001 From: Shay Rojansky Date: Mon, 22 May 2023 14:00:52 +0200 Subject: [PATCH] Normalize Any to Contains instead of vice versa E.g. for easier pattern-matching of Contains --- ...yableMethodTranslatingExpressionVisitor.cs | 26 +- ...yableMethodTranslatingExpressionVisitor.cs | 240 +++++++----------- ...lationalSqlTranslatingExpressionVisitor.cs | 12 +- .../Query/SqlExpressions/ExistsExpression.cs | 7 + .../QueryOptimizingExpressionVisitor.cs | 59 ++--- .../PrimitiveCollectionsQueryTestBase.cs | 16 ++ .../ComplexNavigationsQuerySqlServerTest.cs | 2 +- ...NavigationsSharedTypeQuerySqlServerTest.cs | 2 +- .../Query/GearsOfWarQuerySqlServerTest.cs | 44 ++-- ...indAggregateOperatorsQuerySqlServerTest.cs | 16 +- ...windEFPropertyIncludeQuerySqlServerTest.cs | 16 +- ...windIncludeNoTrackingQuerySqlServerTest.cs | 16 +- .../NorthwindIncludeQuerySqlServerTest.cs | 16 +- ...orthwindMiscellaneousQuerySqlServerTest.cs | 42 +-- .../NorthwindSelectQuerySqlServerTest.cs | 6 +- ...plitIncludeNoTrackingQuerySqlServerTest.cs | 24 +- ...NorthwindSplitIncludeQuerySqlServerTest.cs | 24 +- ...orthwindStringIncludeQuerySqlServerTest.cs | 16 +- .../Query/NorthwindWhereQuerySqlServerTest.cs | 36 +-- .../Query/NullSemanticsQuerySqlServerTest.cs | 40 +-- ...imitiveCollectionsQueryOldSqlServerTest.cs | 24 ++ .../PrimitiveCollectionsQuerySqlServerTest.cs | 24 ++ .../Query/QueryBugsTest.cs | 4 +- .../Query/TPCGearsOfWarQuerySqlServerTest.cs | 32 +-- .../Query/TPTGearsOfWarQuerySqlServerTest.cs | 32 +-- .../TemporalGearsOfWarQuerySqlServerTest.cs | 32 +-- .../Query/UdfDbFunctionSqlServerTests.cs | 16 +- .../Query/GearsOfWarQuerySqliteTest.cs | 16 +- .../PrimitiveCollectionsQuerySqliteTest.cs | 24 ++ 29 files changed, 446 insertions(+), 418 deletions(-) diff --git a/src/EFCore.InMemory/Query/Internal/InMemoryQueryableMethodTranslatingExpressionVisitor.cs b/src/EFCore.InMemory/Query/Internal/InMemoryQueryableMethodTranslatingExpressionVisitor.cs index d1afcca3f2e..f2961ba9cc2 100644 --- a/src/EFCore.InMemory/Query/Internal/InMemoryQueryableMethodTranslatingExpressionVisitor.cs +++ b/src/EFCore.InMemory/Query/Internal/InMemoryQueryableMethodTranslatingExpressionVisitor.cs @@ -236,28 +236,12 @@ private static ShapedQueryExpression CreateShapedQueryExpressionStatic(IEntityTy /// protected override ShapedQueryExpression? TranslateContains(ShapedQueryExpression source, Expression item) { - var inMemoryQueryExpression = (InMemoryQueryExpression)source.QueryExpression; - var newItem = TranslateExpression(item, preserveType: true); - if (newItem == null) - { - return null; - } - - item = newItem; + var anyLambdaParameter = Expression.Parameter(item.Type, "p"); + var anyLambda = Expression.Lambda( + ExpressionExtensions.CreateEqualsExpression(anyLambdaParameter, item), + anyLambdaParameter); - inMemoryQueryExpression.UpdateServerQueryExpression( - Expression.Call( - EnumerableMethods.Contains.MakeGenericMethod(item.Type), - Expression.Call( - EnumerableMethods.Select.MakeGenericMethod(inMemoryQueryExpression.CurrentParameter.Type, item.Type), - inMemoryQueryExpression.ServerQueryExpression, - Expression.Lambda( - inMemoryQueryExpression.GetProjection( - new ProjectionBindingExpression(inMemoryQueryExpression, new ProjectionMember(), item.Type)), - inMemoryQueryExpression.CurrentParameter)), - item)); - - return source.UpdateShaperExpression(Expression.Convert(inMemoryQueryExpression.GetSingleScalarProjection(), typeof(bool))); + return TranslateAny(source, anyLambda); } /// diff --git a/src/EFCore.Relational/Query/RelationalQueryableMethodTranslatingExpressionVisitor.cs b/src/EFCore.Relational/Query/RelationalQueryableMethodTranslatingExpressionVisitor.cs index 900f54abbc1..04e8e1a6847 100644 --- a/src/EFCore.Relational/Query/RelationalQueryableMethodTranslatingExpressionVisitor.cs +++ b/src/EFCore.Relational/Query/RelationalQueryableMethodTranslatingExpressionVisitor.cs @@ -411,33 +411,28 @@ private static ShapedQueryExpression CreateShapedQueryExpression(IEntityType ent return null; } - var selectExpression = (SelectExpression)source.QueryExpression; + var subquery = (SelectExpression)source.QueryExpression; // Negate the predicate, unless it's already negated, in which case remove that. - selectExpression.ApplyPredicate( + subquery.ApplyPredicate( translation is SqlUnaryExpression { OperatorType: ExpressionType.Not, Operand: var nestedOperand } ? nestedOperand : _sqlExpressionFactory.Not(translation)); - if (TrySimplifyValuesToInExpression(source, isNegated: true, out var simplifiedQuery)) - { - return simplifiedQuery; - } - - selectExpression.ReplaceProjection(new List()); - selectExpression.ApplyProjection(); - if (selectExpression.Limit == null - && selectExpression.Offset == null) + subquery.ReplaceProjection(new List()); + subquery.ApplyProjection(); + if (subquery.Limit == null + && subquery.Offset == null) { - selectExpression.ClearOrdering(); + subquery.ClearOrdering(); } - translation = _sqlExpressionFactory.Exists(selectExpression, true); - selectExpression = _sqlExpressionFactory.Select(translation); + translation = _sqlExpressionFactory.Exists(subquery, true); + subquery = _sqlExpressionFactory.Select(translation); return source.Update( - selectExpression, - Expression.Convert(new ProjectionBindingExpression(selectExpression, new ProjectionMember(), typeof(bool?)), typeof(bool))); + subquery, + Expression.Convert(new ProjectionBindingExpression(subquery, new ProjectionMember(), typeof(bool?)), typeof(bool))); } /// @@ -452,24 +447,19 @@ private static ShapedQueryExpression CreateShapedQueryExpression(IEntityType ent } source = translatedSource; - - if (TrySimplifyValuesToInExpression(source, isNegated: false, out var simplifiedQuery)) - { - return simplifiedQuery; - } } - var selectExpression = (SelectExpression)source.QueryExpression; - selectExpression.ReplaceProjection(new List()); - selectExpression.ApplyProjection(); - if (selectExpression.Limit == null - && selectExpression.Offset == null) + var subquery = (SelectExpression)source.QueryExpression; + subquery.ReplaceProjection(new List()); + subquery.ApplyProjection(); + if (subquery.Limit == null + && subquery.Offset == null) { - selectExpression.ClearOrdering(); + subquery.ClearOrdering(); } - var translation = _sqlExpressionFactory.Exists(selectExpression, false); - selectExpression = _sqlExpressionFactory.Select(translation); + var translation = _sqlExpressionFactory.Exists(subquery, false); + var selectExpression = _sqlExpressionFactory.Select(translation); return source.Update( selectExpression, @@ -501,47 +491,65 @@ private static ShapedQueryExpression CreateShapedQueryExpression(IEntityType ent /// protected override ShapedQueryExpression? TranslateContains(ShapedQueryExpression source, Expression item) { - var selectExpression = (SelectExpression)source.QueryExpression; - var translation = TranslateExpression(item); - if (translation == null) - { - return null; - } - - if (selectExpression.Limit == null - && selectExpression.Offset == null) - { - selectExpression.ClearOrdering(); - } - - var shaperExpression = source.ShaperExpression; - // No need to check ConvertChecked since this is convert node which we may have added during projection - if (shaperExpression is UnaryExpression { NodeType: ExpressionType.Convert } unaryExpression - && unaryExpression.Operand.Type.IsNullableType() - && unaryExpression.Operand.Type.UnwrapNullableType() == unaryExpression.Type) - { - shaperExpression = unaryExpression.Operand; - } - - if (shaperExpression is ProjectionBindingExpression projectionBindingExpression) + // Pattern-match Contains over ValuesExpression, translating to simplified 'item IN (1, 2, 3)' with constant elements + if (source.QueryExpression is SelectExpression + { + Tables: + [ + ValuesExpression + { + RowValues: [{ Values.Count: 2 }, ..], + ColumnNames: [ValuesOrderingColumnName, ValuesValueColumnName] + } valuesExpression + ], + Predicate: null, + GroupBy: [], + Having: null, + IsDistinct: false, + Limit: null, + Offset: null, + // Note that in the context of Contains we don't care about orderings + } + // Make sure that the source projects the column from the ValuesExpression directly, i.e. no projection out with some expression + && TryGetProjection(source, out var projection) + && projection is ColumnExpression projectedColumn + && projectedColumn.Table == valuesExpression) { - var projection = selectExpression.GetProjection(projectionBindingExpression); - if (projection is SqlExpression sqlExpression) + if (TranslateExpression(item) is not SqlExpression translatedItem) { - selectExpression.ReplaceProjection(new List { sqlExpression }); - selectExpression.ApplyProjection(); + return null; + } - translation = _sqlExpressionFactory.In(translation, selectExpression, false); - selectExpression = _sqlExpressionFactory.Select(translation); + var values = new object?[valuesExpression.RowValues.Count]; + for (var i = 0; i < values.Length; i++) + { + // Skip the first value (_ord), which is irrelevant for Contains + if (valuesExpression.RowValues[i].Values[1] is SqlConstantExpression { Value: var constantValue }) + { + values[i] = constantValue; + } + else + { + // We only support constants for now + values = null; + break; + } + } - return source.Update( - selectExpression, - Expression.Convert( - new ProjectionBindingExpression(selectExpression, new ProjectionMember(), typeof(bool?)), typeof(bool))); + if (values is not null) + { + var inExpression = _sqlExpressionFactory.In(translatedItem, _sqlExpressionFactory.Constant(values), negated: false); + return source.Update(_sqlExpressionFactory.Select(inExpression), source.ShaperExpression); } } - return null; + // TODO: This generates an EXISTS subquery. Translate to IN instead: #30955 + var anyLambdaParameter = Expression.Parameter(item.Type, "p"); + var anyLambda = Expression.Lambda( + Infrastructure.ExpressionExtensions.CreateEqualsExpression(anyLambdaParameter, item), + anyLambdaParameter); + + return TranslateAny(source, anyLambda); } /// @@ -1812,89 +1820,6 @@ protected virtual Expression ApplyInferredTypeMappings( protected virtual bool IsOrdered(SelectExpression selectExpression) => selectExpression.Orderings.Count > 0; - /// - /// Attempts to pattern-match for Contains over , which corresponds to - /// Where(b => new[] { 1, 2, 3 }.Contains(b.Id)). Simplifies this to the tighter [b].[Id] IN (1, 2, 3) instead of the - /// full subquery with VALUES. - /// - private bool TrySimplifyValuesToInExpression( - ShapedQueryExpression source, - bool isNegated, - [NotNullWhen(true)] out ShapedQueryExpression? simplifiedQuery) - { - if (source.QueryExpression is SelectExpression - { - Tables: [ValuesExpression - { - RowValues: [{ Values.Count: 2 }, ..], - ColumnNames: [ ValuesOrderingColumnName, ValuesValueColumnName ] - } valuesExpression], - GroupBy: [], - Having: null, - IsDistinct: false, - Limit: null, - Offset: null, - // Note that we don't care about orderings, they get elided anyway by Any/All - Predicate: SqlBinaryExpression { OperatorType: ExpressionType.Equal, Left: var left, Right: var right }, - } selectExpression) - { - // The table is a ValuesExpression, and the predicate is an equality - this is a possible simplifiable Contains. - // Get the projection column pointing to the ValuesExpression, and check that it's compared to on one side of the predicate - // equality. - var shaperExpression = source.ShaperExpression; - if (shaperExpression is UnaryExpression { NodeType: ExpressionType.Convert } unaryExpression - && unaryExpression.Operand.Type.IsNullableType() - && unaryExpression.Operand.Type.UnwrapNullableType() == unaryExpression.Type) - { - shaperExpression = unaryExpression.Operand; - } - - if (shaperExpression is ProjectionBindingExpression projectionBindingExpression - && selectExpression.GetProjection(projectionBindingExpression) is ColumnExpression projectionColumn) - { - SqlExpression item; - - if (left is ColumnExpression leftColumn - && (leftColumn.Table, leftColumn.Name) == (projectionColumn.Table, projectionColumn.Name)) - { - item = right; - } - else if (right is ColumnExpression rightColumn - && (rightColumn.Table, rightColumn.Name) == (projectionColumn.Table, projectionColumn.Name)) - { - item = left; - } - else - { - simplifiedQuery = null; - return false; - } - - var values = new object?[valuesExpression.RowValues.Count]; - for (var i = 0; i < values.Length; i++) - { - // Skip the first value (_ord), which is irrelevant for Contains - if (valuesExpression.RowValues[i].Values[1] is SqlConstantExpression { Value: var constantValue }) - { - values[i] = constantValue; - } - else - { - simplifiedQuery = null; - return false; - } - } - - var inExpression = _sqlExpressionFactory.In(item, _sqlExpressionFactory.Constant(values), isNegated); - simplifiedQuery = source.Update(_sqlExpressionFactory.Select(inExpression), source.ShaperExpression); - return true; - } - } - - simplifiedQuery = null; - return false; - } - private Expression RemapLambdaBody(ShapedQueryExpression shapedQueryExpression, LambdaExpression lambdaExpression) { var lambdaBody = ReplacingExpressionVisitor.Replace( @@ -2569,6 +2494,29 @@ private static Expression MatchShaperNullabilityForSetOperation(Expression shape return source.UpdateShaperExpression(shaper); } + private bool TryGetProjection(ShapedQueryExpression shapedQueryExpression, [NotNullWhen(true)] out SqlExpression? projection) + { + var shaperExpression = shapedQueryExpression.ShaperExpression; + // No need to check ConvertChecked since this is convert node which we may have added during projection + if (shaperExpression is UnaryExpression { NodeType: ExpressionType.Convert } unaryExpression + && unaryExpression.Operand.Type.IsNullableType() + && unaryExpression.Operand.Type.UnwrapNullableType() == unaryExpression.Type) + { + shaperExpression = unaryExpression.Operand; + } + + if (shapedQueryExpression.QueryExpression is SelectExpression selectExpression + && shaperExpression is ProjectionBindingExpression projectionBindingExpression + && selectExpression.GetProjection(projectionBindingExpression) is SqlExpression sqlExpression) + { + projection = sqlExpression; + return true; + } + + projection = null; + return false; + } + /// /// A visitor which scans an expression tree and attempts to find columns for which we were missing type mappings (projected out /// of queryable constant/parameter), and those type mappings have been inferred. diff --git a/src/EFCore.Relational/Query/RelationalSqlTranslatingExpressionVisitor.cs b/src/EFCore.Relational/Query/RelationalSqlTranslatingExpressionVisitor.cs index 38569b6d852..f0f490fc73f 100644 --- a/src/EFCore.Relational/Query/RelationalSqlTranslatingExpressionVisitor.cs +++ b/src/EFCore.Relational/Query/RelationalSqlTranslatingExpressionVisitor.cs @@ -1133,9 +1133,7 @@ protected override Expression VisitUnary(UnaryExpression unaryExpression) var operand = Visit(unaryExpression.Operand); if (operand is EntityReferenceExpression entityReferenceExpression - && (unaryExpression.NodeType == ExpressionType.Convert - || unaryExpression.NodeType == ExpressionType.ConvertChecked - || unaryExpression.NodeType == ExpressionType.TypeAs)) + && unaryExpression.NodeType is ExpressionType.Convert or ExpressionType.ConvertChecked or ExpressionType.TypeAs) { return entityReferenceExpression.Convert(unaryExpression.Type); } @@ -1148,7 +1146,13 @@ protected override Expression VisitUnary(UnaryExpression unaryExpression) switch (unaryExpression.NodeType) { case ExpressionType.Not: - return _sqlExpressionFactory.Not(sqlOperand!); + return sqlOperand switch + { + ExistsExpression e => e.Negate(), + InExpression e => e.Negate(), + + _ => _sqlExpressionFactory.Not(sqlOperand!) + }; case ExpressionType.Negate: case ExpressionType.NegateChecked: diff --git a/src/EFCore.Relational/Query/SqlExpressions/ExistsExpression.cs b/src/EFCore.Relational/Query/SqlExpressions/ExistsExpression.cs index 3009d9149c5..21fd656abe0 100644 --- a/src/EFCore.Relational/Query/SqlExpressions/ExistsExpression.cs +++ b/src/EFCore.Relational/Query/SqlExpressions/ExistsExpression.cs @@ -50,6 +50,13 @@ public ExistsExpression( protected override Expression VisitChildren(ExpressionVisitor visitor) => Update((SelectExpression)visitor.Visit(Subquery)); + /// + /// Negates this expression by changing presence/absence state indicated by . + /// + /// An expression which is negated form of this expression. + public virtual ExistsExpression Negate() + => new(Subquery, !IsNegated, TypeMapping); + /// /// Creates a new expression that is like this one, but using the supplied children. If all of the children are the same, it will /// return this expression. diff --git a/src/EFCore/Query/Internal/QueryOptimizingExpressionVisitor.cs b/src/EFCore/Query/Internal/QueryOptimizingExpressionVisitor.cs index cc5c4b9f069..965acfd5f37 100644 --- a/src/EFCore/Query/Internal/QueryOptimizingExpressionVisitor.cs +++ b/src/EFCore/Query/Internal/QueryOptimizingExpressionVisitor.cs @@ -210,44 +210,38 @@ protected override Expression VisitMethodCall(MethodCallExpression methodCallExp result); } + // Normalize x.Any(i => i == foo) to x.Contains(foo) + // And x.All(i => i != foo) to !x.Contains(foo) if (methodCallExpression.Method.IsGenericMethod && methodCallExpression.Method.GetGenericMethodDefinition() is MethodInfo methodInfo - && (methodInfo.Equals(EnumerableMethods.AnyWithPredicate) || methodInfo.Equals(EnumerableMethods.All)) - && methodCallExpression.Arguments[0].NodeType is ExpressionType nodeType - && (nodeType == ExpressionType.Parameter || nodeType == ExpressionType.Constant) - && methodCallExpression.Arguments[1] is LambdaExpression lambda - && TryExtractEqualityOperands(lambda.Body, out var left, out var right, out var negated) - && (left is ParameterExpression || right is ParameterExpression)) + && (methodInfo == EnumerableMethods.AnyWithPredicate || methodInfo == EnumerableMethods.All || methodInfo == QueryableMethods.AnyWithPredicate || methodInfo == QueryableMethods.All) + && methodCallExpression.Arguments[1].UnwrapLambdaFromQuote() is var lambda + && TryExtractEqualityOperands(lambda.Body, out var left, out var right, out var negated)) { - var nonParameterExpression = left is ParameterExpression ? right : left; + var itemExpression = left == lambda.Parameters[0] + ? right + : right == lambda.Parameters[0] + ? left + : null; - if (methodInfo.Equals(EnumerableMethods.AnyWithPredicate) - && !negated) + if (itemExpression is not null) { - var containsMethod = EnumerableMethods.Contains.MakeGenericMethod(methodCallExpression.Method.GetGenericArguments()[0]); - return Expression.Call(null, containsMethod, methodCallExpression.Arguments[0], nonParameterExpression); - } + var containsMethodDefinition = methodInfo.DeclaringType == typeof(Enumerable) + ? EnumerableMethods.Contains + : QueryableMethods.Contains; - if (methodInfo.Equals(EnumerableMethods.All) && negated) - { - var containsMethod = EnumerableMethods.Contains.MakeGenericMethod(methodCallExpression.Method.GetGenericArguments()[0]); - return Expression.Not(Expression.Call(null, containsMethod, methodCallExpression.Arguments[0], nonParameterExpression)); - } - } - - if (methodCallExpression.Method.IsGenericMethod - && methodCallExpression.Method.GetGenericMethodDefinition() is MethodInfo containsMethodInfo - && containsMethodInfo.Equals(QueryableMethods.Contains)) - { - var typeArgument = methodCallExpression.Method.GetGenericArguments()[0]; - var anyMethod = QueryableMethods.AnyWithPredicate.MakeGenericMethod(typeArgument); - - var anyLambdaParameter = Expression.Parameter(typeArgument, "p"); - var anyLambda = Expression.Lambda( - ExpressionExtensions.CreateEqualsExpression(anyLambdaParameter, methodCallExpression.Arguments[1]), - anyLambdaParameter); + if ((methodInfo == EnumerableMethods.AnyWithPredicate || methodInfo == QueryableMethods.AnyWithPredicate) && !negated) + { + var containsMethod = containsMethodDefinition.MakeGenericMethod(methodCallExpression.Method.GetGenericArguments()[0]); + return Expression.Call(null, containsMethod, methodCallExpression.Arguments[0], itemExpression); + } - return Expression.Call(null, anyMethod, new[] { Visit(methodCallExpression.Arguments[0]), anyLambda }); + if ((methodInfo == EnumerableMethods.All || methodInfo == QueryableMethods.All) && negated) + { + var containsMethod = containsMethodDefinition.MakeGenericMethod(methodCallExpression.Method.GetGenericArguments()[0]); + return Expression.Not(Expression.Call(null, containsMethod, methodCallExpression.Arguments[0], itemExpression)); + } + } } var @object = default(Expression); @@ -409,8 +403,7 @@ private static bool TryExtractEqualityOperands( (left, right) = (binaryExpression.Left, binaryExpression.Right); return true; - case MethodCallExpression methodCallExpression - when methodCallExpression.Method.Name == nameof(object.Equals): + case MethodCallExpression { Method.Name: nameof(object.Equals) } methodCallExpression: { negated = false; if (methodCallExpression.Arguments.Count == 1 diff --git a/test/EFCore.Specification.Tests/Query/PrimitiveCollectionsQueryTestBase.cs b/test/EFCore.Specification.Tests/Query/PrimitiveCollectionsQueryTestBase.cs index 1ae89b886bd..5b941c53520 100644 --- a/test/EFCore.Specification.Tests/Query/PrimitiveCollectionsQueryTestBase.cs +++ b/test/EFCore.Specification.Tests/Query/PrimitiveCollectionsQueryTestBase.cs @@ -126,6 +126,22 @@ await AssertTranslationFailed( entryCount: 1)); } + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Inline_collection_Contains_as_Any_with_predicate(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(c => new[] { 2, 999 }.Any(i => i == c.Id)), + entryCount: 1); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Inline_collection_negated_Contains_as_All(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(c => new[] { 2, 999 }.All(i => i != c.Id)), + entryCount: 2); + [ConditionalTheory] [MemberData(nameof(IsAsyncData))] public virtual Task Parameter_collection_Count(bool async) diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/ComplexNavigationsQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/ComplexNavigationsQuerySqlServerTest.cs index 0592e64383f..3b776e520e0 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/ComplexNavigationsQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/ComplexNavigationsQuerySqlServerTest.cs @@ -3084,7 +3084,7 @@ FROM [LevelOne] AS [l] WHERE NOT EXISTS ( SELECT 1 FROM OPENJSON(@__names_0) AS [n] - WHERE ([l0].[Name] = [n].[value] AND [l0].[Name] IS NOT NULL AND [n].[value] IS NOT NULL) OR ([l0].[Name] IS NULL AND [n].[value] IS NULL)) + WHERE [n].[value] = [l0].[Name] OR ([n].[value] IS NULL AND [l0].[Name] IS NULL)) """); } diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/ComplexNavigationsSharedTypeQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/ComplexNavigationsSharedTypeQuerySqlServerTest.cs index 31d674f760a..9d01362a8e4 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/ComplexNavigationsSharedTypeQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/ComplexNavigationsSharedTypeQuerySqlServerTest.cs @@ -5415,7 +5415,7 @@ WHERE [l0].[OneToOne_Required_PK_Date] IS NOT NULL AND [l0].[Level1_Required_Id] WHERE NOT EXISTS ( SELECT 1 FROM OPENJSON(@__names_0) AS [n] - WHERE ([t].[Level2_Name] = [n].[value] AND [t].[Level2_Name] IS NOT NULL AND [n].[value] IS NOT NULL) OR ([t].[Level2_Name] IS NULL AND [n].[value] IS NULL)) + WHERE [n].[value] = [t].[Level2_Name] OR ([n].[value] IS NULL AND [t].[Level2_Name] IS NULL)) """); } diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/GearsOfWarQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/GearsOfWarQuerySqlServerTest.cs index b08baf7124c..111d5855b81 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/GearsOfWarQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/GearsOfWarQuerySqlServerTest.cs @@ -3071,11 +3071,11 @@ public override async Task Any_with_optional_navigation_as_subquery_predicate_is """ SELECT [s].[Name] FROM [Squads] AS [s] -WHERE NOT (EXISTS ( +WHERE NOT EXISTS ( SELECT 1 FROM [Gears] AS [g] LEFT JOIN [Tags] AS [t] ON [g].[Nickname] = [t].[GearNickName] AND [g].[SquadId] = [t].[GearSquadId] - WHERE [s].[Id] = [g].[SquadId] AND [t].[Note] = N'Dom''s Tag')) + WHERE [s].[Id] = [g].[SquadId] AND [t].[Note] = N'Dom''s Tag') """); } @@ -8030,10 +8030,10 @@ FROM [LocustLeaders] AS [l] CROSS APPLY ( SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] FROM [Gears] AS [g] - WHERE NOT (EXISTS ( + WHERE NOT EXISTS ( SELECT 1 FROM [LocustLeaders] AS [l0] - WHERE [l0].[ThreatLevelByte] = [l].[ThreatLevelByte])) + WHERE [l0].[ThreatLevelByte] = [l].[ThreatLevelByte]) ) AS [t] """); } @@ -8068,10 +8068,10 @@ FROM [LocustLeaders] AS [l] CROSS APPLY ( SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] FROM [Gears] AS [g] - WHERE NOT (EXISTS ( + WHERE NOT EXISTS ( SELECT 1 FROM [LocustLeaders] AS [l0] - WHERE [l0].[ThreatLevelNullableByte] = [l].[ThreatLevelNullableByte] OR ([l0].[ThreatLevelNullableByte] IS NULL AND [l].[ThreatLevelNullableByte] IS NULL))) + WHERE [l0].[ThreatLevelNullableByte] = [l].[ThreatLevelNullableByte] OR ([l0].[ThreatLevelNullableByte] IS NULL AND [l].[ThreatLevelNullableByte] IS NULL)) ) AS [t] """); } @@ -9892,10 +9892,10 @@ public override async Task Where_subquery_equality_to_null_with_composite_key(bo """ SELECT [s].[Id], [s].[Banner], [s].[Banner5], [s].[InternalNumber], [s].[Name] FROM [Squads] AS [s] -WHERE NOT (EXISTS ( +WHERE NOT EXISTS ( SELECT 1 FROM [Gears] AS [g] - WHERE [s].[Id] = [g].[SquadId])) + WHERE [s].[Id] = [g].[SquadId]) """); } @@ -9907,10 +9907,10 @@ public override async Task Where_subquery_equality_to_null_without_composite_key """ SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] FROM [Gears] AS [g] -WHERE NOT (EXISTS ( +WHERE NOT EXISTS ( SELECT 1 FROM [Weapons] AS [w] - WHERE [g].[FullName] = [w].[OwnerFullName])) + WHERE [g].[FullName] = [w].[OwnerFullName]) """); } @@ -10007,12 +10007,12 @@ public override async Task Where_subquery_with_ElementAtOrDefault_equality_to_nu """ SELECT [s].[Id], [s].[Banner], [s].[Banner5], [s].[InternalNumber], [s].[Name] FROM [Squads] AS [s] -WHERE NOT (EXISTS ( +WHERE NOT EXISTS ( SELECT 1 FROM [Gears] AS [g] WHERE [s].[Id] = [g].[SquadId] ORDER BY [g].[Nickname] - OFFSET 2 ROWS)) + OFFSET 2 ROWS) """); } @@ -10049,18 +10049,20 @@ public override async Task DateTimeOffset_to_unix_time_milliseconds(bool async) await base.DateTimeOffset_to_unix_time_milliseconds(async); AssertSql( - @"@__unixEpochMilliseconds_0='0' +""" +@__unixEpochMilliseconds_0='0' SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], [s].[Id], [s].[Banner], [s].[Banner5], [s].[InternalNumber], [s].[Name], [s1].[SquadId], [s1].[MissionId] FROM [Gears] AS [g] INNER JOIN [Squads] AS [s] ON [g].[SquadId] = [s].[Id] LEFT JOIN [SquadMissions] AS [s1] ON [s].[Id] = [s1].[SquadId] -WHERE NOT (EXISTS ( +WHERE NOT EXISTS ( SELECT 1 FROM [SquadMissions] AS [s0] INNER JOIN [Missions] AS [m] ON [s0].[MissionId] = [m].[Id] - WHERE [s].[Id] = [s0].[SquadId] AND @__unixEpochMilliseconds_0 = DATEDIFF_BIG(millisecond, '1970-01-01T00:00:00.0000000+00:00', [m].[Timeline]))) -ORDER BY [g].[Nickname], [g].[SquadId], [s].[Id], [s1].[SquadId]"); + WHERE [s].[Id] = [s0].[SquadId] AND @__unixEpochMilliseconds_0 = DATEDIFF_BIG(millisecond, '1970-01-01T00:00:00.0000000+00:00', [m].[Timeline])) +ORDER BY [g].[Nickname], [g].[SquadId], [s].[Id], [s1].[SquadId] +"""); } public override async Task DateTimeOffset_to_unix_time_seconds(bool async) @@ -10068,18 +10070,20 @@ public override async Task DateTimeOffset_to_unix_time_seconds(bool async) await base.DateTimeOffset_to_unix_time_seconds(async); AssertSql( - @"@__unixEpochSeconds_0='0' +""" +@__unixEpochSeconds_0='0' SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], [s].[Id], [s].[Banner], [s].[Banner5], [s].[InternalNumber], [s].[Name], [s1].[SquadId], [s1].[MissionId] FROM [Gears] AS [g] INNER JOIN [Squads] AS [s] ON [g].[SquadId] = [s].[Id] LEFT JOIN [SquadMissions] AS [s1] ON [s].[Id] = [s1].[SquadId] -WHERE NOT (EXISTS ( +WHERE NOT EXISTS ( SELECT 1 FROM [SquadMissions] AS [s0] INNER JOIN [Missions] AS [m] ON [s0].[MissionId] = [m].[Id] - WHERE [s].[Id] = [s0].[SquadId] AND @__unixEpochSeconds_0 = DATEDIFF_BIG(second, '1970-01-01T00:00:00.0000000+00:00', [m].[Timeline]))) -ORDER BY [g].[Nickname], [g].[SquadId], [s].[Id], [s1].[SquadId]"); + WHERE [s].[Id] = [s0].[SquadId] AND @__unixEpochSeconds_0 = DATEDIFF_BIG(second, '1970-01-01T00:00:00.0000000+00:00', [m].[Timeline])) +ORDER BY [g].[Nickname], [g].[SquadId], [s].[Id], [s1].[SquadId] +"""); } public override async Task Set_operator_with_navigation_in_projection_groupby_aggregate(bool async) diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindAggregateOperatorsQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindAggregateOperatorsQuerySqlServerTest.cs index d43f5f6136d..3f459abd147 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindAggregateOperatorsQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindAggregateOperatorsQuerySqlServerTest.cs @@ -1820,10 +1820,10 @@ public override async Task Contains_with_local_collection_false(bool async) 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 NOT (EXISTS ( +WHERE NOT EXISTS ( SELECT 1 FROM OPENJSON(@__ids_0) AS [i] - WHERE CAST([i].[value] AS nchar(5)) = [c].[CustomerID])) + WHERE CAST([i].[value] AS nchar(5)) = [c].[CustomerID]) """); } @@ -2232,10 +2232,10 @@ public override async Task Contains_over_entityType_with_null_should_rewrite_to_ """ SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] FROM [Orders] AS [o] -WHERE NOT (EXISTS ( +WHERE NOT EXISTS ( SELECT 1 FROM [Orders] AS [o0] - WHERE [o0].[CustomerID] = N'VINET' AND [o0].[CustomerID] IS NULL)) + WHERE [o0].[CustomerID] = N'VINET' AND [o0].[CustomerID] IS NULL) """); } @@ -2413,7 +2413,7 @@ FROM [Customers] AS [c] WHERE [c].[City] = N'México D.F.' AND EXISTS ( SELECT 1 FROM OPENJSON(@__ids_0) AS [i] - WHERE [c].[CustomerID] = CAST([i].[value] AS nchar(5))) + WHERE CAST([i].[value] AS nchar(5)) = [c].[CustomerID]) """); } @@ -2430,7 +2430,7 @@ FROM [Customers] AS [c] WHERE NOT EXISTS ( SELECT 1 FROM OPENJSON(@__ids_0) AS [i] - WHERE CAST([i].[value] AS nchar(5)) = [c].[CustomerID] AND [i].[value] IS NOT NULL) + WHERE CAST([i].[value] AS nchar(5)) = [c].[CustomerID]) """); } @@ -2476,7 +2476,7 @@ FROM [Customers] AS [c] WHERE [c].[City] = N'México D.F.' AND NOT EXISTS ( SELECT 1 FROM OPENJSON(@__ids_0) AS [i] - WHERE CAST([i].[value] AS nchar(5)) = [c].[CustomerID] AND [i].[value] IS NOT NULL) + WHERE CAST([i].[value] AS nchar(5)) = [c].[CustomerID]) """, // """ @@ -2487,7 +2487,7 @@ FROM [Customers] AS [c] WHERE [c].[City] = N'México D.F.' AND NOT EXISTS ( SELECT 1 FROM OPENJSON(@__ids_0) AS [i] - WHERE [c].[CustomerID] = CAST([i].[value] AS nchar(5)) AND [i].[value] IS NOT NULL) + WHERE CAST([i].[value] AS nchar(5)) = [c].[CustomerID]) """); } diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindEFPropertyIncludeQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindEFPropertyIncludeQuerySqlServerTest.cs index 027ed68d20f..e47c60ad524 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindEFPropertyIncludeQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindEFPropertyIncludeQuerySqlServerTest.cs @@ -622,19 +622,19 @@ public override async Task Include_collection_OrderBy_list_does_not_contains(boo SELECT [t].[CustomerID], [t].[Address], [t].[City], [t].[CompanyName], [t].[ContactName], [t].[ContactTitle], [t].[Country], [t].[Fax], [t].[Phone], [t].[PostalCode], [t].[Region], [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] FROM ( SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region], CASE - WHEN NOT (EXISTS ( + WHEN NOT EXISTS ( SELECT 1 FROM OPENJSON(@__list_0) AS [l] - WHERE CAST([l].[value] AS nchar(5)) = [c].[CustomerID])) THEN CAST(1 AS bit) + WHERE CAST([l].[value] AS nchar(5)) = [c].[CustomerID]) THEN CAST(1 AS bit) ELSE CAST(0 AS bit) END AS [c] FROM [Customers] AS [c] WHERE [c].[CustomerID] LIKE N'A%' ORDER BY CASE - WHEN NOT (EXISTS ( + WHEN NOT EXISTS ( SELECT 1 FROM OPENJSON(@__list_0) AS [l] - WHERE CAST([l].[value] AS nchar(5)) = [c].[CustomerID])) THEN CAST(1 AS bit) + WHERE CAST([l].[value] AS nchar(5)) = [c].[CustomerID]) THEN CAST(1 AS bit) ELSE CAST(0 AS bit) END OFFSET @__p_1 ROWS @@ -1845,19 +1845,19 @@ public override async Task Include_collection_OrderBy_empty_list_does_not_contai SELECT [t].[CustomerID], [t].[Address], [t].[City], [t].[CompanyName], [t].[ContactName], [t].[ContactTitle], [t].[Country], [t].[Fax], [t].[Phone], [t].[PostalCode], [t].[Region], [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] FROM ( SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region], CASE - WHEN NOT (EXISTS ( + WHEN NOT EXISTS ( SELECT 1 FROM OPENJSON(@__list_0) AS [l] - WHERE CAST([l].[value] AS nchar(5)) = [c].[CustomerID])) THEN CAST(1 AS bit) + WHERE CAST([l].[value] AS nchar(5)) = [c].[CustomerID]) THEN CAST(1 AS bit) ELSE CAST(0 AS bit) END AS [c] FROM [Customers] AS [c] WHERE [c].[CustomerID] LIKE N'A%' ORDER BY CASE - WHEN NOT (EXISTS ( + WHEN NOT EXISTS ( SELECT 1 FROM OPENJSON(@__list_0) AS [l] - WHERE CAST([l].[value] AS nchar(5)) = [c].[CustomerID])) THEN CAST(1 AS bit) + WHERE CAST([l].[value] AS nchar(5)) = [c].[CustomerID]) THEN CAST(1 AS bit) ELSE CAST(0 AS bit) END OFFSET @__p_1 ROWS diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindIncludeNoTrackingQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindIncludeNoTrackingQuerySqlServerTest.cs index e3c55dc1287..92cbf0125f4 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindIncludeNoTrackingQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindIncludeNoTrackingQuerySqlServerTest.cs @@ -176,19 +176,19 @@ public override async Task Include_collection_OrderBy_list_does_not_contains(boo SELECT [t].[CustomerID], [t].[Address], [t].[City], [t].[CompanyName], [t].[ContactName], [t].[ContactTitle], [t].[Country], [t].[Fax], [t].[Phone], [t].[PostalCode], [t].[Region], [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] FROM ( SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region], CASE - WHEN NOT (EXISTS ( + WHEN NOT EXISTS ( SELECT 1 FROM OPENJSON(@__list_0) AS [l] - WHERE CAST([l].[value] AS nchar(5)) = [c].[CustomerID])) THEN CAST(1 AS bit) + WHERE CAST([l].[value] AS nchar(5)) = [c].[CustomerID]) THEN CAST(1 AS bit) ELSE CAST(0 AS bit) END AS [c] FROM [Customers] AS [c] WHERE [c].[CustomerID] LIKE N'A%' ORDER BY CASE - WHEN NOT (EXISTS ( + WHEN NOT EXISTS ( SELECT 1 FROM OPENJSON(@__list_0) AS [l] - WHERE CAST([l].[value] AS nchar(5)) = [c].[CustomerID])) THEN CAST(1 AS bit) + WHERE CAST([l].[value] AS nchar(5)) = [c].[CustomerID]) THEN CAST(1 AS bit) ELSE CAST(0 AS bit) END OFFSET @__p_1 ROWS @@ -2093,19 +2093,19 @@ public override async Task Include_collection_OrderBy_empty_list_does_not_contai SELECT [t].[CustomerID], [t].[Address], [t].[City], [t].[CompanyName], [t].[ContactName], [t].[ContactTitle], [t].[Country], [t].[Fax], [t].[Phone], [t].[PostalCode], [t].[Region], [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] FROM ( SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region], CASE - WHEN NOT (EXISTS ( + WHEN NOT EXISTS ( SELECT 1 FROM OPENJSON(@__list_0) AS [l] - WHERE CAST([l].[value] AS nchar(5)) = [c].[CustomerID])) THEN CAST(1 AS bit) + WHERE CAST([l].[value] AS nchar(5)) = [c].[CustomerID]) THEN CAST(1 AS bit) ELSE CAST(0 AS bit) END AS [c] FROM [Customers] AS [c] WHERE [c].[CustomerID] LIKE N'A%' ORDER BY CASE - WHEN NOT (EXISTS ( + WHEN NOT EXISTS ( SELECT 1 FROM OPENJSON(@__list_0) AS [l] - WHERE CAST([l].[value] AS nchar(5)) = [c].[CustomerID])) THEN CAST(1 AS bit) + WHERE CAST([l].[value] AS nchar(5)) = [c].[CustomerID]) THEN CAST(1 AS bit) ELSE CAST(0 AS bit) END OFFSET @__p_1 ROWS diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindIncludeQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindIncludeQuerySqlServerTest.cs index 19eda4f36a4..bd7634f0388 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindIncludeQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindIncludeQuerySqlServerTest.cs @@ -1543,19 +1543,19 @@ public override async Task Include_collection_OrderBy_empty_list_does_not_contai SELECT [t].[CustomerID], [t].[Address], [t].[City], [t].[CompanyName], [t].[ContactName], [t].[ContactTitle], [t].[Country], [t].[Fax], [t].[Phone], [t].[PostalCode], [t].[Region], [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] FROM ( SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region], CASE - WHEN NOT (EXISTS ( + WHEN NOT EXISTS ( SELECT 1 FROM OPENJSON(@__list_0) AS [l] - WHERE CAST([l].[value] AS nchar(5)) = [c].[CustomerID])) THEN CAST(1 AS bit) + WHERE CAST([l].[value] AS nchar(5)) = [c].[CustomerID]) THEN CAST(1 AS bit) ELSE CAST(0 AS bit) END AS [c] FROM [Customers] AS [c] WHERE [c].[CustomerID] LIKE N'A%' ORDER BY CASE - WHEN NOT (EXISTS ( + WHEN NOT EXISTS ( SELECT 1 FROM OPENJSON(@__list_0) AS [l] - WHERE CAST([l].[value] AS nchar(5)) = [c].[CustomerID])) THEN CAST(1 AS bit) + WHERE CAST([l].[value] AS nchar(5)) = [c].[CustomerID]) THEN CAST(1 AS bit) ELSE CAST(0 AS bit) END OFFSET @__p_1 ROWS @@ -1611,19 +1611,19 @@ public override async Task Include_collection_OrderBy_list_does_not_contains(boo SELECT [t].[CustomerID], [t].[Address], [t].[City], [t].[CompanyName], [t].[ContactName], [t].[ContactTitle], [t].[Country], [t].[Fax], [t].[Phone], [t].[PostalCode], [t].[Region], [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] FROM ( SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region], CASE - WHEN NOT (EXISTS ( + WHEN NOT EXISTS ( SELECT 1 FROM OPENJSON(@__list_0) AS [l] - WHERE CAST([l].[value] AS nchar(5)) = [c].[CustomerID])) THEN CAST(1 AS bit) + WHERE CAST([l].[value] AS nchar(5)) = [c].[CustomerID]) THEN CAST(1 AS bit) ELSE CAST(0 AS bit) END AS [c] FROM [Customers] AS [c] WHERE [c].[CustomerID] LIKE N'A%' ORDER BY CASE - WHEN NOT (EXISTS ( + WHEN NOT EXISTS ( SELECT 1 FROM OPENJSON(@__list_0) AS [l] - WHERE CAST([l].[value] AS nchar(5)) = [c].[CustomerID])) THEN CAST(1 AS bit) + WHERE CAST([l].[value] AS nchar(5)) = [c].[CustomerID]) THEN CAST(1 AS bit) ELSE CAST(0 AS bit) END OFFSET @__p_1 ROWS diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindMiscellaneousQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindMiscellaneousQuerySqlServerTest.cs index 760189f87cd..dd3be5d7c6d 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindMiscellaneousQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindMiscellaneousQuerySqlServerTest.cs @@ -509,10 +509,10 @@ SELECT TOP(@__p_0) [e].[EmployeeID], [e].[City], [e].[Country], [e].[FirstName], FROM [Employees] AS [e] ORDER BY [e].[EmployeeID] ) AS [t] -WHERE NOT (EXISTS ( +WHERE NOT EXISTS ( SELECT 1 FROM [Employees] AS [e0] - WHERE [e0].[EmployeeID] = [t].[ReportsTo])) + WHERE [e0].[EmployeeID] = [t].[ReportsTo]) ORDER BY [t].[EmployeeID] """); } @@ -1502,10 +1502,10 @@ public override async Task Any_nested_negated(bool async) """ 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 NOT (EXISTS ( +WHERE NOT EXISTS ( SELECT 1 FROM [Orders] AS [o] - WHERE [o].[CustomerID] IS NOT NULL AND [o].[CustomerID] LIKE N'A%')) + WHERE [o].[CustomerID] IS NOT NULL AND [o].[CustomerID] LIKE N'A%') """); } @@ -1517,10 +1517,10 @@ public override async Task Any_nested_negated2(bool async) """ 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' OR [c].[City] IS NULL) AND NOT (EXISTS ( +WHERE ([c].[City] <> N'London' OR [c].[City] IS NULL) AND NOT EXISTS ( SELECT 1 FROM [Orders] AS [o] - WHERE [o].[CustomerID] IS NOT NULL AND [o].[CustomerID] LIKE N'A%')) + WHERE [o].[CustomerID] IS NOT NULL AND [o].[CustomerID] LIKE N'A%') """); } @@ -1532,10 +1532,10 @@ public override async Task Any_nested_negated3(bool async) """ 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 NOT (EXISTS ( +WHERE NOT EXISTS ( SELECT 1 FROM [Orders] AS [o] - WHERE [o].[CustomerID] IS NOT NULL AND [o].[CustomerID] LIKE N'A%')) AND ([c].[City] <> N'London' OR [c].[City] IS NULL) + WHERE [o].[CustomerID] IS NOT NULL AND [o].[CustomerID] LIKE N'A%') AND ([c].[City] <> N'London' OR [c].[City] IS NULL) """); } @@ -5105,10 +5105,10 @@ public override async Task OrderBy_empty_list_does_not_contains(bool async) 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] ORDER BY CASE - WHEN NOT (EXISTS ( + WHEN NOT EXISTS ( SELECT 1 FROM OPENJSON(@__list_0) AS [l] - WHERE CAST([l].[value] AS nchar(5)) = [c].[CustomerID])) THEN CAST(1 AS bit) + WHERE CAST([l].[value] AS nchar(5)) = [c].[CustomerID]) THEN CAST(1 AS bit) ELSE CAST(0 AS bit) END """); @@ -5196,10 +5196,10 @@ public override async Task Collection_navigation_equal_to_null_for_subquery(bool """ 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 NOT (EXISTS ( +WHERE NOT EXISTS ( SELECT 1 FROM [Orders] AS [o] - WHERE [c].[CustomerID] = [o].[CustomerID])) + WHERE [c].[CustomerID] = [o].[CustomerID]) """); } @@ -5861,13 +5861,13 @@ public override async Task Entity_equality_on_subquery_with_null_check(bool asyn AssertSql( """ SELECT [c].[CustomerID], CASE - WHEN NOT (EXISTS ( + WHEN NOT EXISTS ( SELECT 1 FROM [Orders] AS [o] - WHERE [c].[CustomerID] = [o].[CustomerID])) OR NOT (EXISTS ( + WHERE [c].[CustomerID] = [o].[CustomerID]) OR NOT EXISTS ( SELECT 1 FROM [Orders] AS [o0] - WHERE [c].[CustomerID] = [o0].[CustomerID])) THEN CAST(1 AS bit) + WHERE [c].[CustomerID] = [o0].[CustomerID]) THEN CAST(1 AS bit) ELSE CAST(0 AS bit) END, ( SELECT TOP(1) [o1].[OrderDate] @@ -7215,10 +7215,10 @@ public override async Task Collection_navigation_equal_to_null_for_subquery_usin """ 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 NOT (EXISTS ( +WHERE NOT EXISTS ( SELECT 1 FROM [Orders] AS [o] - WHERE [c].[CustomerID] = [o].[CustomerID])) + WHERE [c].[CustomerID] = [o].[CustomerID]) """); } @@ -7230,12 +7230,12 @@ public override async Task Collection_navigation_equal_to_null_for_subquery_usin """ 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 NOT (EXISTS ( +WHERE NOT EXISTS ( SELECT 1 FROM [Orders] AS [o] WHERE [c].[CustomerID] = [o].[CustomerID] ORDER BY [o].[OrderID] - OFFSET 1 ROWS)) + OFFSET 1 ROWS) """); } @@ -7249,12 +7249,12 @@ public override async Task Collection_navigation_equal_to_null_for_subquery_usin 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 NOT (EXISTS ( +WHERE NOT EXISTS ( SELECT 1 FROM [Orders] AS [o] WHERE [c].[CustomerID] = [o].[CustomerID] ORDER BY [o].[OrderID] - OFFSET @__prm_0 ROWS)) + OFFSET @__prm_0 ROWS) """); } diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindSelectQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindSelectQuerySqlServerTest.cs index 6617af1c62b..14a62d6a3bf 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindSelectQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindSelectQuerySqlServerTest.cs @@ -1459,13 +1459,13 @@ public override async Task Collection_FirstOrDefault_with_entity_equality_check_ AssertSql( """ SELECT CASE - WHEN NOT (EXISTS ( + WHEN NOT EXISTS ( SELECT 1 FROM [Orders] AS [o] - WHERE [c].[CustomerID] = [o].[CustomerID])) OR NOT (EXISTS ( + WHERE [c].[CustomerID] = [o].[CustomerID]) OR NOT EXISTS ( SELECT 1 FROM [Orders] AS [o0] - WHERE [c].[CustomerID] = [o0].[CustomerID])) THEN CAST(1 AS bit) + WHERE [c].[CustomerID] = [o0].[CustomerID]) THEN CAST(1 AS bit) ELSE CAST(0 AS bit) END FROM [Customers] AS [c] diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindSplitIncludeNoTrackingQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindSplitIncludeNoTrackingQuerySqlServerTest.cs index a1edd9ef0d6..b53644b0bd2 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindSplitIncludeNoTrackingQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindSplitIncludeNoTrackingQuerySqlServerTest.cs @@ -114,10 +114,10 @@ public override async Task Include_collection_OrderBy_list_does_not_contains(boo FROM [Customers] AS [c] WHERE [c].[CustomerID] LIKE N'A%' ORDER BY CASE - WHEN NOT (EXISTS ( + WHEN NOT EXISTS ( SELECT 1 FROM OPENJSON(@__list_0) AS [l] - WHERE CAST([l].[value] AS nchar(5)) = [c].[CustomerID])) THEN CAST(1 AS bit) + WHERE CAST([l].[value] AS nchar(5)) = [c].[CustomerID]) THEN CAST(1 AS bit) ELSE CAST(0 AS bit) END, [c].[CustomerID] OFFSET @__p_1 ROWS @@ -130,19 +130,19 @@ OFFSET @__p_1 ROWS SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate], [t].[CustomerID] FROM ( SELECT [c].[CustomerID], CASE - WHEN NOT (EXISTS ( + WHEN NOT EXISTS ( SELECT 1 FROM OPENJSON(@__list_0) AS [l] - WHERE CAST([l].[value] AS nchar(5)) = [c].[CustomerID])) THEN CAST(1 AS bit) + WHERE CAST([l].[value] AS nchar(5)) = [c].[CustomerID]) THEN CAST(1 AS bit) ELSE CAST(0 AS bit) END AS [c] FROM [Customers] AS [c] WHERE [c].[CustomerID] LIKE N'A%' ORDER BY CASE - WHEN NOT (EXISTS ( + WHEN NOT EXISTS ( SELECT 1 FROM OPENJSON(@__list_0) AS [l] - WHERE CAST([l].[value] AS nchar(5)) = [c].[CustomerID])) THEN CAST(1 AS bit) + WHERE CAST([l].[value] AS nchar(5)) = [c].[CustomerID]) THEN CAST(1 AS bit) ELSE CAST(0 AS bit) END OFFSET @__p_1 ROWS @@ -1737,10 +1737,10 @@ public override async Task Include_collection_OrderBy_empty_list_does_not_contai FROM [Customers] AS [c] WHERE [c].[CustomerID] LIKE N'A%' ORDER BY CASE - WHEN NOT (EXISTS ( + WHEN NOT EXISTS ( SELECT 1 FROM OPENJSON(@__list_0) AS [l] - WHERE CAST([l].[value] AS nchar(5)) = [c].[CustomerID])) THEN CAST(1 AS bit) + WHERE CAST([l].[value] AS nchar(5)) = [c].[CustomerID]) THEN CAST(1 AS bit) ELSE CAST(0 AS bit) END, [c].[CustomerID] OFFSET @__p_1 ROWS @@ -1753,19 +1753,19 @@ OFFSET @__p_1 ROWS SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate], [t].[CustomerID] FROM ( SELECT [c].[CustomerID], CASE - WHEN NOT (EXISTS ( + WHEN NOT EXISTS ( SELECT 1 FROM OPENJSON(@__list_0) AS [l] - WHERE CAST([l].[value] AS nchar(5)) = [c].[CustomerID])) THEN CAST(1 AS bit) + WHERE CAST([l].[value] AS nchar(5)) = [c].[CustomerID]) THEN CAST(1 AS bit) ELSE CAST(0 AS bit) END AS [c] FROM [Customers] AS [c] WHERE [c].[CustomerID] LIKE N'A%' ORDER BY CASE - WHEN NOT (EXISTS ( + WHEN NOT EXISTS ( SELECT 1 FROM OPENJSON(@__list_0) AS [l] - WHERE CAST([l].[value] AS nchar(5)) = [c].[CustomerID])) THEN CAST(1 AS bit) + WHERE CAST([l].[value] AS nchar(5)) = [c].[CustomerID]) THEN CAST(1 AS bit) ELSE CAST(0 AS bit) END OFFSET @__p_1 ROWS diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindSplitIncludeQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindSplitIncludeQuerySqlServerTest.cs index 5b735dfda5e..09d6100122a 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindSplitIncludeQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindSplitIncludeQuerySqlServerTest.cs @@ -2104,10 +2104,10 @@ public override async Task Include_collection_OrderBy_empty_list_does_not_contai FROM [Customers] AS [c] WHERE [c].[CustomerID] LIKE N'A%' ORDER BY CASE - WHEN NOT (EXISTS ( + WHEN NOT EXISTS ( SELECT 1 FROM OPENJSON(@__list_0) AS [l] - WHERE CAST([l].[value] AS nchar(5)) = [c].[CustomerID])) THEN CAST(1 AS bit) + WHERE CAST([l].[value] AS nchar(5)) = [c].[CustomerID]) THEN CAST(1 AS bit) ELSE CAST(0 AS bit) END, [c].[CustomerID] OFFSET @__p_1 ROWS @@ -2120,19 +2120,19 @@ OFFSET @__p_1 ROWS SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate], [t].[CustomerID] FROM ( SELECT [c].[CustomerID], CASE - WHEN NOT (EXISTS ( + WHEN NOT EXISTS ( SELECT 1 FROM OPENJSON(@__list_0) AS [l] - WHERE CAST([l].[value] AS nchar(5)) = [c].[CustomerID])) THEN CAST(1 AS bit) + WHERE CAST([l].[value] AS nchar(5)) = [c].[CustomerID]) THEN CAST(1 AS bit) ELSE CAST(0 AS bit) END AS [c] FROM [Customers] AS [c] WHERE [c].[CustomerID] LIKE N'A%' ORDER BY CASE - WHEN NOT (EXISTS ( + WHEN NOT EXISTS ( SELECT 1 FROM OPENJSON(@__list_0) AS [l] - WHERE CAST([l].[value] AS nchar(5)) = [c].[CustomerID])) THEN CAST(1 AS bit) + WHERE CAST([l].[value] AS nchar(5)) = [c].[CustomerID]) THEN CAST(1 AS bit) ELSE CAST(0 AS bit) END OFFSET @__p_1 ROWS @@ -2206,10 +2206,10 @@ public override async Task Include_collection_OrderBy_list_does_not_contains(boo FROM [Customers] AS [c] WHERE [c].[CustomerID] LIKE N'A%' ORDER BY CASE - WHEN NOT (EXISTS ( + WHEN NOT EXISTS ( SELECT 1 FROM OPENJSON(@__list_0) AS [l] - WHERE CAST([l].[value] AS nchar(5)) = [c].[CustomerID])) THEN CAST(1 AS bit) + WHERE CAST([l].[value] AS nchar(5)) = [c].[CustomerID]) THEN CAST(1 AS bit) ELSE CAST(0 AS bit) END, [c].[CustomerID] OFFSET @__p_1 ROWS @@ -2222,19 +2222,19 @@ OFFSET @__p_1 ROWS SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate], [t].[CustomerID] FROM ( SELECT [c].[CustomerID], CASE - WHEN NOT (EXISTS ( + WHEN NOT EXISTS ( SELECT 1 FROM OPENJSON(@__list_0) AS [l] - WHERE CAST([l].[value] AS nchar(5)) = [c].[CustomerID])) THEN CAST(1 AS bit) + WHERE CAST([l].[value] AS nchar(5)) = [c].[CustomerID]) THEN CAST(1 AS bit) ELSE CAST(0 AS bit) END AS [c] FROM [Customers] AS [c] WHERE [c].[CustomerID] LIKE N'A%' ORDER BY CASE - WHEN NOT (EXISTS ( + WHEN NOT EXISTS ( SELECT 1 FROM OPENJSON(@__list_0) AS [l] - WHERE CAST([l].[value] AS nchar(5)) = [c].[CustomerID])) THEN CAST(1 AS bit) + WHERE CAST([l].[value] AS nchar(5)) = [c].[CustomerID]) THEN CAST(1 AS bit) ELSE CAST(0 AS bit) END OFFSET @__p_1 ROWS diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindStringIncludeQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindStringIncludeQuerySqlServerTest.cs index b9d189aff18..cae3e2f3b4e 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindStringIncludeQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindStringIncludeQuerySqlServerTest.cs @@ -622,19 +622,19 @@ public override async Task Include_collection_OrderBy_list_does_not_contains(boo SELECT [t].[CustomerID], [t].[Address], [t].[City], [t].[CompanyName], [t].[ContactName], [t].[ContactTitle], [t].[Country], [t].[Fax], [t].[Phone], [t].[PostalCode], [t].[Region], [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] FROM ( SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region], CASE - WHEN NOT (EXISTS ( + WHEN NOT EXISTS ( SELECT 1 FROM OPENJSON(@__list_0) AS [l] - WHERE CAST([l].[value] AS nchar(5)) = [c].[CustomerID])) THEN CAST(1 AS bit) + WHERE CAST([l].[value] AS nchar(5)) = [c].[CustomerID]) THEN CAST(1 AS bit) ELSE CAST(0 AS bit) END AS [c] FROM [Customers] AS [c] WHERE [c].[CustomerID] LIKE N'A%' ORDER BY CASE - WHEN NOT (EXISTS ( + WHEN NOT EXISTS ( SELECT 1 FROM OPENJSON(@__list_0) AS [l] - WHERE CAST([l].[value] AS nchar(5)) = [c].[CustomerID])) THEN CAST(1 AS bit) + WHERE CAST([l].[value] AS nchar(5)) = [c].[CustomerID]) THEN CAST(1 AS bit) ELSE CAST(0 AS bit) END OFFSET @__p_1 ROWS @@ -1845,19 +1845,19 @@ public override async Task Include_collection_OrderBy_empty_list_does_not_contai SELECT [t].[CustomerID], [t].[Address], [t].[City], [t].[CompanyName], [t].[ContactName], [t].[ContactTitle], [t].[Country], [t].[Fax], [t].[Phone], [t].[PostalCode], [t].[Region], [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] FROM ( SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region], CASE - WHEN NOT (EXISTS ( + WHEN NOT EXISTS ( SELECT 1 FROM OPENJSON(@__list_0) AS [l] - WHERE CAST([l].[value] AS nchar(5)) = [c].[CustomerID])) THEN CAST(1 AS bit) + WHERE CAST([l].[value] AS nchar(5)) = [c].[CustomerID]) THEN CAST(1 AS bit) ELSE CAST(0 AS bit) END AS [c] FROM [Customers] AS [c] WHERE [c].[CustomerID] LIKE N'A%' ORDER BY CASE - WHEN NOT (EXISTS ( + WHEN NOT EXISTS ( SELECT 1 FROM OPENJSON(@__list_0) AS [l] - WHERE CAST([l].[value] AS nchar(5)) = [c].[CustomerID])) THEN CAST(1 AS bit) + WHERE CAST([l].[value] AS nchar(5)) = [c].[CustomerID]) THEN CAST(1 AS bit) ELSE CAST(0 AS bit) END OFFSET @__p_1 ROWS diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindWhereQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindWhereQuerySqlServerTest.cs index 419ed693a18..4e68138bfe5 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindWhereQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindWhereQuerySqlServerTest.cs @@ -1967,10 +1967,10 @@ public override async Task Where_subquery_FirstOrDefault_is_null(bool async) """ 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 NOT (EXISTS ( +WHERE NOT EXISTS ( SELECT 1 FROM [Orders] AS [o] - WHERE [c].[CustomerID] = [o].[CustomerID])) + WHERE [c].[CustomerID] = [o].[CustomerID]) """); } @@ -2256,10 +2256,10 @@ public override async Task Where_Queryable_AsEnumerable_Contains_negated(bool as SELECT [c].[CustomerID], [o0].[CustomerID], [o0].[OrderID] FROM [Customers] AS [c] LEFT JOIN [Orders] AS [o0] ON [c].[CustomerID] = [o0].[CustomerID] -WHERE NOT (EXISTS ( +WHERE NOT EXISTS ( SELECT 1 FROM [Orders] AS [o] - WHERE [o].[CustomerID] = [c].[CustomerID] AND [o].[CustomerID] = N'ALFKI')) + WHERE [o].[CustomerID] = [c].[CustomerID] AND [o].[CustomerID] = N'ALFKI') ORDER BY [c].[CustomerID] """); } @@ -2716,10 +2716,10 @@ public override async Task FirstOrDefault_over_custom_projection_compared_to_nul """ 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 NOT (EXISTS ( +WHERE NOT EXISTS ( SELECT 1 FROM [Orders] AS [o] - WHERE [c].[CustomerID] = [o].[CustomerID])) + WHERE [c].[CustomerID] = [o].[CustomerID]) """); } @@ -2746,10 +2746,10 @@ public override async Task SingleOrDefault_over_custom_projection_compared_to_nu """ 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 NOT (EXISTS ( +WHERE NOT EXISTS ( SELECT 1 FROM [Orders] AS [o] - WHERE [c].[CustomerID] = [o].[CustomerID])) + WHERE [c].[CustomerID] = [o].[CustomerID]) """); } @@ -2776,10 +2776,10 @@ public override async Task LastOrDefault_over_custom_projection_compared_to_null """ 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 NOT (EXISTS ( +WHERE NOT EXISTS ( SELECT 1 FROM [Orders] AS [o] - WHERE [c].[CustomerID] = [o].[CustomerID])) + WHERE [c].[CustomerID] = [o].[CustomerID]) """); } @@ -2806,10 +2806,10 @@ public override async Task First_over_custom_projection_compared_to_null(bool as """ 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 NOT (EXISTS ( +WHERE NOT EXISTS ( SELECT 1 FROM [Orders] AS [o] - WHERE [c].[CustomerID] = [o].[CustomerID])) + WHERE [c].[CustomerID] = [o].[CustomerID]) """); } @@ -2853,12 +2853,12 @@ public override async Task ElementAtOrDefault_over_custom_projection_compared_to """ 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 NOT (EXISTS ( +WHERE NOT EXISTS ( SELECT 1 FROM [Orders] AS [o] WHERE [c].[CustomerID] = [o].[CustomerID] ORDER BY (SELECT 1) - OFFSET 7 ROWS)) + OFFSET 7 ROWS) """); } @@ -2870,10 +2870,10 @@ public override async Task Single_over_custom_projection_compared_to_null(bool a """ 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 NOT (EXISTS ( +WHERE NOT EXISTS ( SELECT 1 FROM [Orders] AS [o] - WHERE [c].[CustomerID] = [o].[CustomerID])) + WHERE [c].[CustomerID] = [o].[CustomerID]) """); } @@ -2900,10 +2900,10 @@ public override async Task Last_over_custom_projection_compared_to_null(bool asy """ 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 NOT (EXISTS ( +WHERE NOT EXISTS ( SELECT 1 FROM [Orders] AS [o] - WHERE [c].[CustomerID] = [o].[CustomerID])) + WHERE [c].[CustomerID] = [o].[CustomerID]) """); } diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/NullSemanticsQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/NullSemanticsQuerySqlServerTest.cs index 9703e1e3af3..79c6dc8fbc6 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/NullSemanticsQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/NullSemanticsQuerySqlServerTest.cs @@ -932,10 +932,10 @@ public override async Task Contains_with_local_array_closure_false_with_null(boo SELECT [e].[Id] FROM [Entities1] AS [e] -WHERE NOT (EXISTS ( +WHERE NOT EXISTS ( SELECT 1 FROM OPENJSON(@__ids_0) AS [i] - WHERE [i].[value] = [e].[NullableStringA] OR ([i].[value] IS NULL AND [e].[NullableStringA] IS NULL))) + WHERE [i].[value] = [e].[NullableStringA] OR ([i].[value] IS NULL AND [e].[NullableStringA] IS NULL)) """); } @@ -949,10 +949,10 @@ public override async Task Contains_with_local_nullable_array_closure_negated(bo SELECT [e].[Id] FROM [Entities1] AS [e] -WHERE NOT (EXISTS ( +WHERE NOT EXISTS ( SELECT 1 FROM OPENJSON(@__ids_0) AS [i] - WHERE [i].[value] = [e].[NullableStringA] OR ([i].[value] IS NULL AND [e].[NullableStringA] IS NULL))) + WHERE [i].[value] = [e].[NullableStringA] OR ([i].[value] IS NULL AND [e].[NullableStringA] IS NULL)) """); } @@ -1795,10 +1795,10 @@ WHERE CAST([i].[value] AS int) = [e].[NullableIntA] OR ([i].[value] IS NULL AND SELECT [e].[Id] FROM [Entities1] AS [e] -WHERE NOT (EXISTS ( +WHERE NOT EXISTS ( SELECT 1 FROM OPENJSON(@__ids_0) AS [i] - WHERE CAST([i].[value] AS int) = [e].[NullableIntA] OR ([i].[value] IS NULL AND [e].[NullableIntA] IS NULL))) + WHERE CAST([i].[value] AS int) = [e].[NullableIntA] OR ([i].[value] IS NULL AND [e].[NullableIntA] IS NULL)) """, // """ @@ -1817,10 +1817,10 @@ WHERE CAST([i].[value] AS int) = [e].[NullableIntA] OR ([i].[value] IS NULL AND SELECT [e].[Id] FROM [Entities1] AS [e] -WHERE NOT (EXISTS ( +WHERE NOT EXISTS ( SELECT 1 FROM OPENJSON(@__ids2_0) AS [i] - WHERE CAST([i].[value] AS int) = [e].[NullableIntA] OR ([i].[value] IS NULL AND [e].[NullableIntA] IS NULL))) + WHERE CAST([i].[value] AS int) = [e].[NullableIntA] OR ([i].[value] IS NULL AND [e].[NullableIntA] IS NULL)) """, // """ @@ -1869,10 +1869,10 @@ WHERE CAST([i].[value] AS int) = [e].[NullableIntA] OR ([i].[value] IS NULL AND SELECT [e].[Id] FROM [Entities1] AS [e] -WHERE NOT (EXISTS ( +WHERE NOT EXISTS ( SELECT 1 FROM OPENJSON(@__ids_0) AS [i] - WHERE CAST([i].[value] AS int) = [e].[NullableIntA] OR ([i].[value] IS NULL AND [e].[NullableIntA] IS NULL))) + WHERE CAST([i].[value] AS int) = [e].[NullableIntA] OR ([i].[value] IS NULL AND [e].[NullableIntA] IS NULL)) """, // """ @@ -1891,10 +1891,10 @@ WHERE CAST([i].[value] AS int) = [e].[NullableIntA] OR ([i].[value] IS NULL AND SELECT [e].[Id] FROM [Entities1] AS [e] -WHERE NOT (EXISTS ( +WHERE NOT EXISTS ( SELECT 1 FROM OPENJSON(@__ids2_0) AS [i] - WHERE CAST([i].[value] AS int) = [e].[NullableIntA] OR ([i].[value] IS NULL AND [e].[NullableIntA] IS NULL))) + WHERE CAST([i].[value] AS int) = [e].[NullableIntA] OR ([i].[value] IS NULL AND [e].[NullableIntA] IS NULL)) """, // """ @@ -1942,10 +1942,10 @@ WHERE CAST([i].[value] AS int) = [e].[IntA]) SELECT [e].[Id] FROM [Entities1] AS [e] -WHERE NOT (EXISTS ( +WHERE NOT EXISTS ( SELECT 1 FROM OPENJSON(@__ids_0) AS [i] - WHERE CAST([i].[value] AS int) = [e].[IntA])) + WHERE CAST([i].[value] AS int) = [e].[IntA]) """, // """ @@ -1964,10 +1964,10 @@ WHERE CAST([i].[value] AS int) = [e].[IntA]) SELECT [e].[Id] FROM [Entities1] AS [e] -WHERE NOT (EXISTS ( +WHERE NOT EXISTS ( SELECT 1 FROM OPENJSON(@__ids2_0) AS [i] - WHERE CAST([i].[value] AS int) = [e].[IntA])) + WHERE CAST([i].[value] AS int) = [e].[IntA]) """, // """ @@ -1986,10 +1986,10 @@ WHERE CAST([i].[value] AS int) = [e].[IntA]) SELECT [e].[Id] FROM [Entities1] AS [e] -WHERE NOT (EXISTS ( +WHERE NOT EXISTS ( SELECT 1 FROM OPENJSON(@__ids3_0) AS [i] - WHERE CAST([i].[value] AS int) = [e].[IntA])) + WHERE CAST([i].[value] AS int) = [e].[IntA]) """, // """ @@ -2008,10 +2008,10 @@ WHERE CAST([i].[value] AS int) = [e].[IntA]) SELECT [e].[Id] FROM [Entities1] AS [e] -WHERE NOT (EXISTS ( +WHERE NOT EXISTS ( SELECT 1 FROM OPENJSON(@__ids4_0) AS [i] - WHERE CAST([i].[value] AS int) = [e].[IntA])) + WHERE CAST([i].[value] AS int) = [e].[IntA]) """); } diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/PrimitiveCollectionsQueryOldSqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/PrimitiveCollectionsQueryOldSqlServerTest.cs index ed3a176b359..0748763df67 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/PrimitiveCollectionsQueryOldSqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/PrimitiveCollectionsQueryOldSqlServerTest.cs @@ -164,6 +164,30 @@ public override async Task Inline_collection_Contains_with_parameter_and_column_ AssertSql(); } + public override async Task Inline_collection_Contains_as_Any_with_predicate(bool async) + { + await base.Inline_collection_Contains_as_Any_with_predicate(async); + + AssertSql( +""" +SELECT [p].[Id], [p].[Bool], [p].[Bools], [p].[DateTime], [p].[DateTimes], [p].[Enum], [p].[Enums], [p].[Int], [p].[Ints], [p].[NullableInt], [p].[NullableInts], [p].[String], [p].[Strings] +FROM [PrimitiveCollectionsEntity] AS [p] +WHERE [p].[Id] IN (2, 999) +"""); + } + + public override async Task Inline_collection_negated_Contains_as_All(bool async) + { + await base.Inline_collection_negated_Contains_as_All(async); + + AssertSql( +""" +SELECT [p].[Id], [p].[Bool], [p].[Bools], [p].[DateTime], [p].[DateTimes], [p].[Enum], [p].[Enums], [p].[Int], [p].[Ints], [p].[NullableInt], [p].[NullableInts], [p].[String], [p].[Strings] +FROM [PrimitiveCollectionsEntity] AS [p] +WHERE [p].[Id] NOT IN (2, 999) +"""); + } + public override Task Parameter_collection_Count(bool async) => AssertTranslationFailed(() => base.Parameter_collection_Count(async)); diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/PrimitiveCollectionsQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/PrimitiveCollectionsQuerySqlServerTest.cs index 7b6051fc93c..6dff82ec517 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/PrimitiveCollectionsQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/PrimitiveCollectionsQuerySqlServerTest.cs @@ -166,6 +166,30 @@ public override async Task Inline_collection_Contains_with_parameter_and_column_ AssertSql(); } + public override async Task Inline_collection_Contains_as_Any_with_predicate(bool async) + { + await base.Inline_collection_Contains_as_Any_with_predicate(async); + + AssertSql( +""" +SELECT [p].[Id], [p].[Bool], [p].[Bools], [p].[DateTime], [p].[DateTimes], [p].[Enum], [p].[Enums], [p].[Int], [p].[Ints], [p].[NullableInt], [p].[NullableInts], [p].[String], [p].[Strings] +FROM [PrimitiveCollectionsEntity] AS [p] +WHERE [p].[Id] IN (2, 999) +"""); + } + + public override async Task Inline_collection_negated_Contains_as_All(bool async) + { + await base.Inline_collection_negated_Contains_as_All(async); + + AssertSql( +""" +SELECT [p].[Id], [p].[Bool], [p].[Bools], [p].[DateTime], [p].[DateTimes], [p].[Enum], [p].[Enums], [p].[Int], [p].[Ints], [p].[NullableInt], [p].[NullableInts], [p].[String], [p].[Strings] +FROM [PrimitiveCollectionsEntity] AS [p] +WHERE [p].[Id] NOT IN (2, 999) +"""); + } + public override async Task Parameter_collection_Count(bool async) { await base.Parameter_collection_Count(async); diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/QueryBugsTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/QueryBugsTest.cs index e3758dddc3d..34d2f662f12 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/QueryBugsTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/QueryBugsTest.cs @@ -8894,10 +8894,10 @@ public virtual async Task Query_filter_with_contains_evaluates_correctly() SELECT [e].[Id], [e].[Name] FROM [Entities] AS [e] -WHERE NOT (EXISTS ( +WHERE NOT EXISTS ( SELECT 1 FROM OPENJSON(@__ef_filter___ids_0) AS [e0] - WHERE CAST([e0].[value] AS int) = [e].[Id])) + WHERE CAST([e0].[value] AS int) = [e].[Id]) """); } } diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/TPCGearsOfWarQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/TPCGearsOfWarQuerySqlServerTest.cs index 1b24c4a3855..043be0c6f33 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/TPCGearsOfWarQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/TPCGearsOfWarQuerySqlServerTest.cs @@ -4101,7 +4101,7 @@ public override async Task Any_with_optional_navigation_as_subquery_predicate_is """ SELECT [s].[Name] FROM [Squads] AS [s] -WHERE NOT (EXISTS ( +WHERE NOT EXISTS ( SELECT 1 FROM ( SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] @@ -4111,7 +4111,7 @@ UNION ALL FROM [Officers] AS [o] ) AS [t] LEFT JOIN [Tags] AS [t0] ON [t].[Nickname] = [t0].[GearNickName] AND [t].[SquadId] = [t0].[GearSquadId] - WHERE [s].[Id] = [t].[SquadId] AND [t0].[Note] = N'Dom''s Tag')) + WHERE [s].[Id] = [t].[SquadId] AND [t0].[Note] = N'Dom''s Tag') """); } @@ -10689,7 +10689,7 @@ UNION ALL SELECT [o].[Nickname], [o].[SquadId], [o].[AssignedCityName], [o].[CityOfBirthName], [o].[FullName], [o].[HasSoulPatch], [o].[LeaderNickname], [o].[LeaderSquadId], [o].[Rank], N'Officer' AS [Discriminator] FROM [Officers] AS [o] ) AS [t0] - WHERE NOT (EXISTS ( + WHERE NOT EXISTS ( SELECT 1 FROM ( SELECT [l1].[Name], [l1].[LocustHordeId], [l1].[ThreatLevel], [l1].[ThreatLevelByte], [l1].[ThreatLevelNullableByte], NULL AS [DefeatedByNickname], NULL AS [DefeatedBySquadId], NULL AS [HighCommandId], N'LocustLeader' AS [Discriminator] @@ -10698,7 +10698,7 @@ UNION ALL SELECT [l2].[Name], [l2].[LocustHordeId], [l2].[ThreatLevel], [l2].[ThreatLevelByte], [l2].[ThreatLevelNullableByte], [l2].[DefeatedByNickname], [l2].[DefeatedBySquadId], [l2].[HighCommandId], N'LocustCommander' AS [Discriminator] FROM [LocustCommanders] AS [l2] ) AS [t2] - WHERE [t2].[ThreatLevelByte] = [t].[ThreatLevelByte])) + WHERE [t2].[ThreatLevelByte] = [t].[ThreatLevelByte]) ) AS [t1] """); } @@ -10763,7 +10763,7 @@ UNION ALL SELECT [o].[Nickname], [o].[SquadId], [o].[AssignedCityName], [o].[CityOfBirthName], [o].[FullName], [o].[HasSoulPatch], [o].[LeaderNickname], [o].[LeaderSquadId], [o].[Rank], N'Officer' AS [Discriminator] FROM [Officers] AS [o] ) AS [t0] - WHERE NOT (EXISTS ( + WHERE NOT EXISTS ( SELECT 1 FROM ( SELECT [l1].[Name], [l1].[LocustHordeId], [l1].[ThreatLevel], [l1].[ThreatLevelByte], [l1].[ThreatLevelNullableByte], NULL AS [DefeatedByNickname], NULL AS [DefeatedBySquadId], NULL AS [HighCommandId], N'LocustLeader' AS [Discriminator] @@ -10772,7 +10772,7 @@ UNION ALL SELECT [l2].[Name], [l2].[LocustHordeId], [l2].[ThreatLevel], [l2].[ThreatLevelByte], [l2].[ThreatLevelNullableByte], [l2].[DefeatedByNickname], [l2].[DefeatedBySquadId], [l2].[HighCommandId], N'LocustCommander' AS [Discriminator] FROM [LocustCommanders] AS [l2] ) AS [t2] - WHERE [t2].[ThreatLevelNullableByte] = [t].[ThreatLevelNullableByte] OR ([t2].[ThreatLevelNullableByte] IS NULL AND [t].[ThreatLevelNullableByte] IS NULL))) + WHERE [t2].[ThreatLevelNullableByte] = [t].[ThreatLevelNullableByte] OR ([t2].[ThreatLevelNullableByte] IS NULL AND [t].[ThreatLevelNullableByte] IS NULL)) ) AS [t1] """); } @@ -12989,7 +12989,7 @@ public override async Task Where_subquery_equality_to_null_with_composite_key(bo """ SELECT [s].[Id], [s].[Banner], [s].[Banner5], [s].[InternalNumber], [s].[Name] FROM [Squads] AS [s] -WHERE NOT (EXISTS ( +WHERE NOT EXISTS ( SELECT 1 FROM ( SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] @@ -12998,7 +12998,7 @@ UNION ALL SELECT [o].[Nickname], [o].[SquadId], [o].[AssignedCityName], [o].[CityOfBirthName], [o].[FullName], [o].[HasSoulPatch], [o].[LeaderNickname], [o].[LeaderSquadId], [o].[Rank], N'Officer' AS [Discriminator] FROM [Officers] AS [o] ) AS [t] - WHERE [s].[Id] = [t].[SquadId])) + WHERE [s].[Id] = [t].[SquadId]) """); } @@ -13016,10 +13016,10 @@ UNION ALL SELECT [o].[Nickname], [o].[SquadId], [o].[AssignedCityName], [o].[CityOfBirthName], [o].[FullName], [o].[HasSoulPatch], [o].[LeaderNickname], [o].[LeaderSquadId], [o].[Rank], N'Officer' AS [Discriminator] FROM [Officers] AS [o] ) AS [t] -WHERE NOT (EXISTS ( +WHERE NOT EXISTS ( SELECT 1 FROM [Weapons] AS [w] - WHERE [t].[FullName] = [w].[OwnerFullName])) + WHERE [t].[FullName] = [w].[OwnerFullName]) """); } @@ -13165,7 +13165,7 @@ public override async Task Where_subquery_with_ElementAtOrDefault_equality_to_nu """ SELECT [s].[Id], [s].[Banner], [s].[Banner5], [s].[InternalNumber], [s].[Name] FROM [Squads] AS [s] -WHERE NOT (EXISTS ( +WHERE NOT EXISTS ( SELECT 1 FROM ( SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] @@ -13176,7 +13176,7 @@ FROM [Officers] AS [o] ) AS [t] WHERE [s].[Id] = [t].[SquadId] ORDER BY [t].[Nickname] - OFFSET 2 ROWS)) + OFFSET 2 ROWS) """); } @@ -13232,11 +13232,11 @@ FROM [Officers] AS [o] ) AS [t] INNER JOIN [Squads] AS [s] ON [t].[SquadId] = [s].[Id] LEFT JOIN [SquadMissions] AS [s1] ON [s].[Id] = [s1].[SquadId] -WHERE NOT (EXISTS ( +WHERE NOT EXISTS ( SELECT 1 FROM [SquadMissions] AS [s0] INNER JOIN [Missions] AS [m] ON [s0].[MissionId] = [m].[Id] - WHERE [s].[Id] = [s0].[SquadId] AND @__unixEpochMilliseconds_0 = DATEDIFF_BIG(millisecond, '1970-01-01T00:00:00.0000000+00:00', [m].[Timeline]))) + WHERE [s].[Id] = [s0].[SquadId] AND @__unixEpochMilliseconds_0 = DATEDIFF_BIG(millisecond, '1970-01-01T00:00:00.0000000+00:00', [m].[Timeline])) ORDER BY [t].[Nickname], [t].[SquadId], [s].[Id], [s1].[SquadId] """); } @@ -13259,11 +13259,11 @@ FROM [Officers] AS [o] ) AS [t] INNER JOIN [Squads] AS [s] ON [t].[SquadId] = [s].[Id] LEFT JOIN [SquadMissions] AS [s1] ON [s].[Id] = [s1].[SquadId] -WHERE NOT (EXISTS ( +WHERE NOT EXISTS ( SELECT 1 FROM [SquadMissions] AS [s0] INNER JOIN [Missions] AS [m] ON [s0].[MissionId] = [m].[Id] - WHERE [s].[Id] = [s0].[SquadId] AND @__unixEpochSeconds_0 = DATEDIFF_BIG(second, '1970-01-01T00:00:00.0000000+00:00', [m].[Timeline]))) + WHERE [s].[Id] = [s0].[SquadId] AND @__unixEpochSeconds_0 = DATEDIFF_BIG(second, '1970-01-01T00:00:00.0000000+00:00', [m].[Timeline])) ORDER BY [t].[Nickname], [t].[SquadId], [s].[Id], [s1].[SquadId] """); } diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/TPTGearsOfWarQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/TPTGearsOfWarQuerySqlServerTest.cs index 689cc666e7d..7849b346fe6 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/TPTGearsOfWarQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/TPTGearsOfWarQuerySqlServerTest.cs @@ -3532,12 +3532,12 @@ public override async Task Any_with_optional_navigation_as_subquery_predicate_is """ SELECT [s].[Name] FROM [Squads] AS [s] -WHERE NOT (EXISTS ( +WHERE NOT EXISTS ( SELECT 1 FROM [Gears] AS [g] LEFT JOIN [Officers] AS [o] ON [g].[Nickname] = [o].[Nickname] AND [g].[SquadId] = [o].[SquadId] LEFT JOIN [Tags] AS [t] ON [g].[Nickname] = [t].[GearNickName] AND [g].[SquadId] = [t].[GearSquadId] - WHERE [s].[Id] = [g].[SquadId] AND [t].[Note] = N'Dom''s Tag')) + WHERE [s].[Id] = [g].[SquadId] AND [t].[Note] = N'Dom''s Tag') """); } @@ -9157,11 +9157,11 @@ WHEN [o].[Nickname] IS NOT NULL THEN N'Officer' END AS [Discriminator] FROM [Gears] AS [g] LEFT JOIN [Officers] AS [o] ON [g].[Nickname] = [o].[Nickname] AND [g].[SquadId] = [o].[SquadId] - WHERE NOT (EXISTS ( + WHERE NOT EXISTS ( SELECT 1 FROM [LocustLeaders] AS [l1] LEFT JOIN [LocustCommanders] AS [l2] ON [l1].[Name] = [l2].[Name] - WHERE [l1].[ThreatLevelByte] = [l].[ThreatLevelByte])) + WHERE [l1].[ThreatLevelByte] = [l].[ThreatLevelByte]) ) AS [t] """); } @@ -9203,11 +9203,11 @@ WHEN [o].[Nickname] IS NOT NULL THEN N'Officer' END AS [Discriminator] FROM [Gears] AS [g] LEFT JOIN [Officers] AS [o] ON [g].[Nickname] = [o].[Nickname] AND [g].[SquadId] = [o].[SquadId] - WHERE NOT (EXISTS ( + WHERE NOT EXISTS ( SELECT 1 FROM [LocustLeaders] AS [l1] LEFT JOIN [LocustCommanders] AS [l2] ON [l1].[Name] = [l2].[Name] - WHERE [l1].[ThreatLevelNullableByte] = [l].[ThreatLevelNullableByte] OR ([l1].[ThreatLevelNullableByte] IS NULL AND [l].[ThreatLevelNullableByte] IS NULL))) + WHERE [l1].[ThreatLevelNullableByte] = [l].[ThreatLevelNullableByte] OR ([l1].[ThreatLevelNullableByte] IS NULL AND [l].[ThreatLevelNullableByte] IS NULL)) ) AS [t] """); } @@ -11183,11 +11183,11 @@ public override async Task Where_subquery_equality_to_null_with_composite_key(bo """ SELECT [s].[Id], [s].[Banner], [s].[Banner5], [s].[InternalNumber], [s].[Name] FROM [Squads] AS [s] -WHERE NOT (EXISTS ( +WHERE NOT EXISTS ( SELECT 1 FROM [Gears] AS [g] LEFT JOIN [Officers] AS [o] ON [g].[Nickname] = [o].[Nickname] AND [g].[SquadId] = [o].[SquadId] - WHERE [s].[Id] = [g].[SquadId])) + WHERE [s].[Id] = [g].[SquadId]) """); } @@ -11202,10 +11202,10 @@ WHEN [o].[Nickname] IS NOT NULL THEN N'Officer' END AS [Discriminator] FROM [Gears] AS [g] LEFT JOIN [Officers] AS [o] ON [g].[Nickname] = [o].[Nickname] AND [g].[SquadId] = [o].[SquadId] -WHERE NOT (EXISTS ( +WHERE NOT EXISTS ( SELECT 1 FROM [Weapons] AS [w] - WHERE [g].[FullName] = [w].[OwnerFullName])) + WHERE [g].[FullName] = [w].[OwnerFullName]) """); } @@ -11337,13 +11337,13 @@ public override async Task Where_subquery_with_ElementAtOrDefault_equality_to_nu """ SELECT [s].[Id], [s].[Banner], [s].[Banner5], [s].[InternalNumber], [s].[Name] FROM [Squads] AS [s] -WHERE NOT (EXISTS ( +WHERE NOT EXISTS ( SELECT 1 FROM [Gears] AS [g] LEFT JOIN [Officers] AS [o] ON [g].[Nickname] = [o].[Nickname] AND [g].[SquadId] = [o].[SquadId] WHERE [s].[Id] = [g].[SquadId] ORDER BY [g].[Nickname] - OFFSET 2 ROWS)) + OFFSET 2 ROWS) """); } @@ -11391,11 +11391,11 @@ FROM [Gears] AS [g] LEFT JOIN [Officers] AS [o] ON [g].[Nickname] = [o].[Nickname] AND [g].[SquadId] = [o].[SquadId] INNER JOIN [Squads] AS [s] ON [g].[SquadId] = [s].[Id] LEFT JOIN [SquadMissions] AS [s1] ON [s].[Id] = [s1].[SquadId] -WHERE NOT (EXISTS ( +WHERE NOT EXISTS ( SELECT 1 FROM [SquadMissions] AS [s0] INNER JOIN [Missions] AS [m] ON [s0].[MissionId] = [m].[Id] - WHERE [s].[Id] = [s0].[SquadId] AND @__unixEpochMilliseconds_0 = DATEDIFF_BIG(millisecond, '1970-01-01T00:00:00.0000000+00:00', [m].[Timeline]))) + WHERE [s].[Id] = [s0].[SquadId] AND @__unixEpochMilliseconds_0 = DATEDIFF_BIG(millisecond, '1970-01-01T00:00:00.0000000+00:00', [m].[Timeline])) ORDER BY [g].[Nickname], [g].[SquadId], [s].[Id], [s1].[SquadId] """); } @@ -11415,11 +11415,11 @@ FROM [Gears] AS [g] LEFT JOIN [Officers] AS [o] ON [g].[Nickname] = [o].[Nickname] AND [g].[SquadId] = [o].[SquadId] INNER JOIN [Squads] AS [s] ON [g].[SquadId] = [s].[Id] LEFT JOIN [SquadMissions] AS [s1] ON [s].[Id] = [s1].[SquadId] -WHERE NOT (EXISTS ( +WHERE NOT EXISTS ( SELECT 1 FROM [SquadMissions] AS [s0] INNER JOIN [Missions] AS [m] ON [s0].[MissionId] = [m].[Id] - WHERE [s].[Id] = [s0].[SquadId] AND @__unixEpochSeconds_0 = DATEDIFF_BIG(second, '1970-01-01T00:00:00.0000000+00:00', [m].[Timeline]))) + WHERE [s].[Id] = [s0].[SquadId] AND @__unixEpochSeconds_0 = DATEDIFF_BIG(second, '1970-01-01T00:00:00.0000000+00:00', [m].[Timeline])) ORDER BY [g].[Nickname], [g].[SquadId], [s].[Id], [s1].[SquadId] """); } diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/TemporalGearsOfWarQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/TemporalGearsOfWarQuerySqlServerTest.cs index ea02cf7d036..3da4aa91429 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/TemporalGearsOfWarQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/TemporalGearsOfWarQuerySqlServerTest.cs @@ -548,11 +548,11 @@ public override async Task Any_with_optional_navigation_as_subquery_predicate_is """ SELECT [s].[Name] FROM [Squads] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [s] -WHERE NOT (EXISTS ( +WHERE NOT EXISTS ( SELECT 1 FROM [Gears] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [g] LEFT JOIN [Tags] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [t] ON [g].[Nickname] = [t].[GearNickName] AND [g].[SquadId] = [t].[GearSquadId] - WHERE [s].[Id] = [g].[SquadId] AND [t].[Note] = N'Dom''s Tag')) + WHERE [s].[Id] = [g].[SquadId] AND [t].[Note] = N'Dom''s Tag') """); } @@ -2947,10 +2947,10 @@ public override async Task Subquery_projecting_non_nullable_scalar_contains_non_ CROSS APPLY ( SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[PeriodEnd], [g].[PeriodStart], [g].[Rank] FROM [Gears] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [g] - WHERE NOT (EXISTS ( + WHERE NOT EXISTS ( SELECT 1 FROM [LocustLeaders] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [l0] - WHERE [l0].[ThreatLevelByte] = [l].[ThreatLevelByte])) + WHERE [l0].[ThreatLevelByte] = [l].[ThreatLevelByte]) ) AS [t] """); } @@ -4467,10 +4467,10 @@ public override async Task Subquery_projecting_nullable_scalar_contains_nullable CROSS APPLY ( SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[PeriodEnd], [g].[PeriodStart], [g].[Rank] FROM [Gears] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [g] - WHERE NOT (EXISTS ( + WHERE NOT EXISTS ( SELECT 1 FROM [LocustLeaders] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [l0] - WHERE [l0].[ThreatLevelNullableByte] = [l].[ThreatLevelNullableByte] OR ([l0].[ThreatLevelNullableByte] IS NULL AND [l].[ThreatLevelNullableByte] IS NULL))) + WHERE [l0].[ThreatLevelNullableByte] = [l].[ThreatLevelNullableByte] OR ([l0].[ThreatLevelNullableByte] IS NULL AND [l].[ThreatLevelNullableByte] IS NULL)) ) AS [t] """); } @@ -9810,10 +9810,10 @@ public override async Task Where_subquery_equality_to_null_with_composite_key(bo """ SELECT [s].[Id], [s].[Banner], [s].[Banner5], [s].[InternalNumber], [s].[Name], [s].[PeriodEnd], [s].[PeriodStart] FROM [Squads] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [s] -WHERE NOT (EXISTS ( +WHERE NOT EXISTS ( SELECT 1 FROM [Gears] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [g] - WHERE [s].[Id] = [g].[SquadId])) + WHERE [s].[Id] = [g].[SquadId]) """); } @@ -9825,10 +9825,10 @@ public override async Task Where_subquery_equality_to_null_without_composite_key """ SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[PeriodEnd], [g].[PeriodStart], [g].[Rank] FROM [Gears] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [g] -WHERE NOT (EXISTS ( +WHERE NOT EXISTS ( SELECT 1 FROM [Weapons] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [w] - WHERE [g].[FullName] = [w].[OwnerFullName])) + WHERE [g].[FullName] = [w].[OwnerFullName]) """); } @@ -9913,12 +9913,12 @@ public override async Task Where_subquery_with_ElementAtOrDefault_equality_to_nu """ SELECT [s].[Id], [s].[Banner], [s].[Banner5], [s].[InternalNumber], [s].[Name], [s].[PeriodEnd], [s].[PeriodStart] FROM [Squads] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [s] -WHERE NOT (EXISTS ( +WHERE NOT EXISTS ( SELECT 1 FROM [Gears] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [g] WHERE [s].[Id] = [g].[SquadId] ORDER BY [g].[Nickname] - OFFSET 2 ROWS)) + OFFSET 2 ROWS) """); } @@ -9962,11 +9962,11 @@ public override async Task DateTimeOffset_to_unix_time_milliseconds(bool async) FROM [Gears] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [g] INNER JOIN [Squads] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [s] ON [g].[SquadId] = [s].[Id] LEFT JOIN [SquadMissions] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [s1] ON [s].[Id] = [s1].[SquadId] -WHERE NOT (EXISTS ( +WHERE NOT EXISTS ( SELECT 1 FROM [SquadMissions] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [s0] INNER JOIN [Missions] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [m] ON [s0].[MissionId] = [m].[Id] - WHERE [s].[Id] = [s0].[SquadId] AND @__unixEpochMilliseconds_0 = DATEDIFF_BIG(millisecond, '1970-01-01T00:00:00.0000000+00:00', [m].[Timeline]))) + WHERE [s].[Id] = [s0].[SquadId] AND @__unixEpochMilliseconds_0 = DATEDIFF_BIG(millisecond, '1970-01-01T00:00:00.0000000+00:00', [m].[Timeline])) ORDER BY [g].[Nickname], [g].[SquadId], [s].[Id], [s1].[SquadId] """); } @@ -9983,11 +9983,11 @@ public override async Task DateTimeOffset_to_unix_time_seconds(bool async) FROM [Gears] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [g] INNER JOIN [Squads] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [s] ON [g].[SquadId] = [s].[Id] LEFT JOIN [SquadMissions] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [s1] ON [s].[Id] = [s1].[SquadId] -WHERE NOT (EXISTS ( +WHERE NOT EXISTS ( SELECT 1 FROM [SquadMissions] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [s0] INNER JOIN [Missions] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [m] ON [s0].[MissionId] = [m].[Id] - WHERE [s].[Id] = [s0].[SquadId] AND @__unixEpochSeconds_0 = DATEDIFF_BIG(second, '1970-01-01T00:00:00.0000000+00:00', [m].[Timeline]))) + WHERE [s].[Id] = [s0].[SquadId] AND @__unixEpochSeconds_0 = DATEDIFF_BIG(second, '1970-01-01T00:00:00.0000000+00:00', [m].[Timeline])) ORDER BY [g].[Nickname], [g].[SquadId], [s].[Id], [s1].[SquadId] """); } diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/UdfDbFunctionSqlServerTests.cs b/test/EFCore.SqlServer.FunctionalTests/Query/UdfDbFunctionSqlServerTests.cs index 3113d18a51f..aeb735fce1b 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/UdfDbFunctionSqlServerTests.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/UdfDbFunctionSqlServerTests.cs @@ -910,16 +910,16 @@ SELECT COALESCE(SUM(CAST(LEN([c1].[FirstName]) AS int)), 0) FROM [Orders] AS [o0] INNER JOIN [Customers] AS [c0] ON [o0].[CustomerId] = [c0].[Id] INNER JOIN [Customers] AS [c1] ON [o0].[CustomerId] = [c1].[Id] - WHERE NOT (EXISTS ( + WHERE NOT EXISTS ( SELECT 1 FROM [dbo].[GetTopTwoSellingProducts]() AS [g0] - WHERE [g0].[ProductId] = 25)) AND ([c].[LastName] = [c0].[LastName] OR ([c].[LastName] IS NULL AND [c0].[LastName] IS NULL))) AS [SumOfLengths] + WHERE [g0].[ProductId] = 25) AND ([c].[LastName] = [c0].[LastName] OR ([c].[LastName] IS NULL AND [c0].[LastName] IS NULL))) AS [SumOfLengths] FROM [Orders] AS [o] INNER JOIN [Customers] AS [c] ON [o].[CustomerId] = [c].[Id] -WHERE NOT (EXISTS ( +WHERE NOT EXISTS ( SELECT 1 FROM [dbo].[GetTopTwoSellingProducts]() AS [g] - WHERE [g].[ProductId] = 25)) + WHERE [g].[ProductId] = 25) GROUP BY [c].[LastName] """); } @@ -935,22 +935,22 @@ SELECT COALESCE(SUM(CAST(LEN([c2].[FirstName]) AS int)), 0) FROM [Orders] AS [o0] INNER JOIN [Customers] AS [c1] ON [o0].[CustomerId] = [c1].[Id] INNER JOIN [Customers] AS [c2] ON [o0].[CustomerId] = [c2].[Id] - WHERE NOT (EXISTS ( + WHERE NOT EXISTS ( SELECT 1 FROM [dbo].[GetOrdersWithMultipleProducts](( SELECT TOP(1) [c3].[Id] FROM [Customers] AS [c3] ORDER BY [c3].[Id])) AS [g0] - WHERE [g0].[CustomerId] = 25)) AND ([c0].[LastName] = [c1].[LastName] OR ([c0].[LastName] IS NULL AND [c1].[LastName] IS NULL))) AS [SumOfLengths] + WHERE [g0].[CustomerId] = 25) AND ([c0].[LastName] = [c1].[LastName] OR ([c0].[LastName] IS NULL AND [c1].[LastName] IS NULL))) AS [SumOfLengths] FROM [Orders] AS [o] INNER JOIN [Customers] AS [c0] ON [o].[CustomerId] = [c0].[Id] -WHERE NOT (EXISTS ( +WHERE NOT EXISTS ( SELECT 1 FROM [dbo].[GetOrdersWithMultipleProducts](( SELECT TOP(1) [c].[Id] FROM [Customers] AS [c] ORDER BY [c].[Id])) AS [g] - WHERE [g].[CustomerId] = 25)) + WHERE [g].[CustomerId] = 25) GROUP BY [c0].[LastName] """); } diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/GearsOfWarQuerySqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/Query/GearsOfWarQuerySqliteTest.cs index 59a8e40e39d..be87fb50ab5 100644 --- a/test/EFCore.Sqlite.FunctionalTests/Query/GearsOfWarQuerySqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/Query/GearsOfWarQuerySqliteTest.cs @@ -1422,11 +1422,11 @@ public override async Task Any_with_optional_navigation_as_subquery_predicate_is """ SELECT "s"."Name" FROM "Squads" AS "s" -WHERE NOT (EXISTS ( +WHERE NOT EXISTS ( SELECT 1 FROM "Gears" AS "g" LEFT JOIN "Tags" AS "t" ON "g"."Nickname" = "t"."GearNickName" AND "g"."SquadId" = "t"."GearSquadId" - WHERE "s"."Id" = "g"."SquadId" AND "t"."Note" = 'Dom''s Tag')) + WHERE "s"."Id" = "g"."SquadId" AND "t"."Note" = 'Dom''s Tag') """); } @@ -9298,10 +9298,10 @@ public override async Task Where_subquery_equality_to_null_with_composite_key(bo """ SELECT "s"."Id", "s"."Banner", "s"."Banner5", "s"."InternalNumber", "s"."Name" FROM "Squads" AS "s" -WHERE NOT (EXISTS ( +WHERE NOT EXISTS ( SELECT 1 FROM "Gears" AS "g" - WHERE "s"."Id" = "g"."SquadId")) + WHERE "s"."Id" = "g"."SquadId") """); } @@ -9313,10 +9313,10 @@ public override async Task Where_subquery_equality_to_null_without_composite_key """ SELECT "g"."Nickname", "g"."SquadId", "g"."AssignedCityName", "g"."CityOfBirthName", "g"."Discriminator", "g"."FullName", "g"."HasSoulPatch", "g"."LeaderNickname", "g"."LeaderSquadId", "g"."Rank" FROM "Gears" AS "g" -WHERE NOT (EXISTS ( +WHERE NOT EXISTS ( SELECT 1 FROM "Weapons" AS "w" - WHERE "g"."FullName" = "w"."OwnerFullName")) + WHERE "g"."FullName" = "w"."OwnerFullName") """); } @@ -9412,12 +9412,12 @@ public override async Task Where_subquery_with_ElementAtOrDefault_equality_to_nu """ SELECT "s"."Id", "s"."Banner", "s"."Banner5", "s"."InternalNumber", "s"."Name" FROM "Squads" AS "s" -WHERE NOT (EXISTS ( +WHERE NOT EXISTS ( SELECT 1 FROM "Gears" AS "g" WHERE "s"."Id" = "g"."SquadId" ORDER BY "g"."Nickname" - LIMIT -1 OFFSET 2)) + LIMIT -1 OFFSET 2) """); } diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/PrimitiveCollectionsQuerySqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/Query/PrimitiveCollectionsQuerySqliteTest.cs index 8fc5012b386..4d632724f6d 100644 --- a/test/EFCore.Sqlite.FunctionalTests/Query/PrimitiveCollectionsQuerySqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/Query/PrimitiveCollectionsQuerySqliteTest.cs @@ -168,6 +168,30 @@ public override async Task Inline_collection_Contains_with_parameter_and_column_ AssertSql(); } + public override async Task Inline_collection_Contains_as_Any_with_predicate(bool async) + { + await base.Inline_collection_Contains_as_Any_with_predicate(async); + + AssertSql( +""" +SELECT "p"."Id", "p"."Bool", "p"."Bools", "p"."DateTime", "p"."DateTimes", "p"."Enum", "p"."Enums", "p"."Int", "p"."Ints", "p"."NullableInt", "p"."NullableInts", "p"."String", "p"."Strings" +FROM "PrimitiveCollectionsEntity" AS "p" +WHERE "p"."Id" IN (2, 999) +"""); + } + + public override async Task Inline_collection_negated_Contains_as_All(bool async) + { + await base.Inline_collection_negated_Contains_as_All(async); + + AssertSql( +""" +SELECT "p"."Id", "p"."Bool", "p"."Bools", "p"."DateTime", "p"."DateTimes", "p"."Enum", "p"."Enums", "p"."Int", "p"."Ints", "p"."NullableInt", "p"."NullableInts", "p"."String", "p"."Strings" +FROM "PrimitiveCollectionsEntity" AS "p" +WHERE "p"."Id" NOT IN (2, 999) +"""); + } + public override async Task Parameter_collection_Count(bool async) { await base.Parameter_collection_Count(async);