From de12606ba242d32ed5d5e6105e3ecc100c597a8b Mon Sep 17 00:00:00 2001 From: Smit Patel Date: Fri, 30 Aug 2019 11:59:19 -0700 Subject: [PATCH] InMemory: Preserve type of value buffer expressions when doing Join/SelectMany Part of #16963 --- .../Query/Internal/InMemoryQueryExpression.cs | 15 ++++++---- .../ComplexNavigationsQueryInMemoryTest.cs | 6 ---- ...ComplexNavigationsWeakQueryInMemoryTest.cs | 30 ------------------- 3 files changed, 9 insertions(+), 42 deletions(-) diff --git a/src/EFCore.InMemory/Query/Internal/InMemoryQueryExpression.cs b/src/EFCore.InMemory/Query/Internal/InMemoryQueryExpression.cs index 4cba1dd1af6..5cdd06a4291 100644 --- a/src/EFCore.InMemory/Query/Internal/InMemoryQueryExpression.cs +++ b/src/EFCore.InMemory/Query/Internal/InMemoryQueryExpression.cs @@ -472,8 +472,9 @@ public virtual void AddInnerJoin( var readExpressionMap = new Dictionary(); foreach (var property in GetAllPropertiesInHierarchy(entityProjection.EntityType)) { - resultValueBufferExpressions.Add(replacingVisitor.Visit(entityProjection.BindProperty(property))); - readExpressionMap[property] = CreateReadValueExpression(property.ClrType, index++, property); + var replacedExpression = replacingVisitor.Visit(entityProjection.BindProperty(property)); + resultValueBufferExpressions.Add(replacedExpression); + readExpressionMap[property] = CreateReadValueExpression(replacedExpression.Type, index++, property); } projectionMapping[projection.Key.Prepend(outerMemberInfo)] = new EntityProjectionExpression(entityProjection.EntityType, readExpressionMap); @@ -494,8 +495,9 @@ public virtual void AddInnerJoin( var readExpressionMap = new Dictionary(); foreach (var property in GetAllPropertiesInHierarchy(entityProjection.EntityType)) { - resultValueBufferExpressions.Add(replacingVisitor.Visit(entityProjection.BindProperty(property))); - readExpressionMap[property] = CreateReadValueExpression(property.ClrType, index++, property); + var replacedExpression = replacingVisitor.Visit(entityProjection.BindProperty(property)); + resultValueBufferExpressions.Add(replacedExpression); + readExpressionMap[property] = CreateReadValueExpression(replacedExpression.Type, index++, property); } projectionMapping[projection.Key.Prepend(innerMemberInfo)] = new EntityProjectionExpression(entityProjection.EntityType, readExpressionMap); @@ -683,8 +685,9 @@ public virtual void AddSelectMany(InMemoryQueryExpression innerQueryExpression, var readExpressionMap = new Dictionary(); foreach (var property in GetAllPropertiesInHierarchy(entityProjection.EntityType)) { - resultValueBufferExpressions.Add(replacingVisitor.Visit(entityProjection.BindProperty(property))); - readExpressionMap[property] = CreateReadValueExpression(property.ClrType, index++, property); + var replacedExpression = replacingVisitor.Visit(entityProjection.BindProperty(property)); + resultValueBufferExpressions.Add(replacedExpression); + readExpressionMap[property] = CreateReadValueExpression(replacedExpression.Type, index++, property); } projectionMapping[projection.Key.Prepend(outerMemberInfo)] = new EntityProjectionExpression(entityProjection.EntityType, readExpressionMap); diff --git a/test/EFCore.InMemory.FunctionalTests/Query/ComplexNavigationsQueryInMemoryTest.cs b/test/EFCore.InMemory.FunctionalTests/Query/ComplexNavigationsQueryInMemoryTest.cs index ba3e2f3384d..e34e6ee35ee 100644 --- a/test/EFCore.InMemory.FunctionalTests/Query/ComplexNavigationsQueryInMemoryTest.cs +++ b/test/EFCore.InMemory.FunctionalTests/Query/ComplexNavigationsQueryInMemoryTest.cs @@ -75,12 +75,6 @@ public override Task SelectMany_nested_navigation_property_required(bool isAsync return base.SelectMany_nested_navigation_property_required(isAsync); } - [ConditionalTheory(Skip = "issue #16963 Test")] - public override Task Join_flattening_bug_4539(bool isAsync) - { - return base.Join_flattening_bug_4539(isAsync); - } - [ConditionalTheory(Skip = "issue #16963 Test")] public override Task Include18_3_3(bool isAsync) { diff --git a/test/EFCore.InMemory.FunctionalTests/Query/ComplexNavigationsWeakQueryInMemoryTest.cs b/test/EFCore.InMemory.FunctionalTests/Query/ComplexNavigationsWeakQueryInMemoryTest.cs index 3bc1141ac05..3637547868b 100644 --- a/test/EFCore.InMemory.FunctionalTests/Query/ComplexNavigationsWeakQueryInMemoryTest.cs +++ b/test/EFCore.InMemory.FunctionalTests/Query/ComplexNavigationsWeakQueryInMemoryTest.cs @@ -24,12 +24,6 @@ public override Task Complex_query_with_optional_navigations_and_client_side_eva return base.Complex_query_with_optional_navigations_and_client_side_evaluation(isAsync); } - [ConditionalTheory(Skip = "Issue#16963 Too Many Results")] - public override Task Complex_navigations_with_predicate_projected_into_anonymous_type(bool isAsync) - { - return base.Complex_navigations_with_predicate_projected_into_anonymous_type(isAsync); - } - [ConditionalTheory(Skip = "issue #16963 TooManyResults")] public override Task SelectMany_with_nested_navigations_and_explicit_DefaultIfEmpty_followed_by_Select_required_navigation_using_different_navs(bool isAsync) { @@ -84,36 +78,12 @@ public override Task Join_with_navigations_in_the_result_selector1(bool isAsync) return base.Join_with_navigations_in_the_result_selector1(isAsync); } - [ConditionalTheory(Skip = "issue #16963 Test")] - public override Task Include10(bool isAsync) - { - return base.Include10(isAsync); - } - - [ConditionalTheory(Skip = "issue #16963 Test")] - public override Task Include11(bool isAsync) - { - return base.Include11(isAsync); - } - [ConditionalTheory(Skip = "issue #16963 Test")] public override Task Include18_3_3(bool isAsync) { return base.Include18_3_3(isAsync); } - [ConditionalTheory(Skip = "issue #16963 Test")] - public override Task Multiple_include_with_multiple_optional_navigations(bool isAsync) - { - return base.Multiple_include_with_multiple_optional_navigations(isAsync); - } - - [ConditionalTheory(Skip = "issue #16963 Test")] - public override Task Order_by_key_of_anonymous_type_projected_navigation_doesnt_get_optimized_into_FK_access_subquery(bool isAsync) - { - return base.Order_by_key_of_anonymous_type_projected_navigation_doesnt_get_optimized_into_FK_access_subquery(isAsync); - } - [ConditionalTheory(Skip = "issue #16963 Test")] public override Task Where_nav_prop_reference_optional1_via_DefaultIfEmpty(bool isAsync) {