Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include before Concat throws on nav rewrite #13196

Closed
AndriySvyryd opened this issue Sep 3, 2018 · 2 comments · Fixed by #16249 or #16339
Closed

Include before Concat throws on nav rewrite #13196

AndriySvyryd opened this issue Sep 3, 2018 · 2 comments · Fixed by #16249 or #16339
Assignees
Labels
closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. type-bug
Milestone

Comments

@AndriySvyryd
Copy link
Member

[ConditionalFact]
public virtual void Include_before_Concat()
{
    using(var context = CreateContext())
    {
        context.Customers.Include(c => c.Orders).Concat(context.Customers).ToList();
    }
}

System.ArgumentException : The input sequence must have items of type 'Microsoft.EntityFrameworkCore.TestModels.Northwind.Customer', but it has items of type 'Microsoft.EntityFrameworkCore.Query.Internal.AnonymousObject'.
Parameter name: inputInfo
at Remotion.Linq.Clauses.ResultOperatorBase.CheckSequenceItemType(StreamedSequenceInfo inputInfo, Type expectedItemType)
at Remotion.Linq.Clauses.ResultOperators.ConcatResultOperator.GetOutputDataInfo(IStreamedDataInfo inputInfo)
at System.Linq.Enumerable.Aggregate[TSource,TAccumulate](IEnumerable1 source, TAccumulate seed, Func3 func)
at Remotion.Linq.QueryModel.GetOutputDataInfo()
at Remotion.Linq.Clauses.Expressions.SubQueryExpression..ctor(QueryModel queryModel)
at Microsoft.EntityFrameworkCore.Query.Internal.IncludeCompiler.CollectionQueryModelRewritingExpressionVisitor.CreateJoinToParentQuery(QueryModel parentQueryModel, QuerySourceReferenceExpression parentQuerySourceReferenceExpression, Expression outerTargetExpression, IForeignKey foreignKey, QueryModel targetQueryModel, ICollection1 subQueryProjection) in C:\enlistments\Universe\EntityFramework\src\EFCore\Query\Internal\IncludeCompiler.CollectionQueryModelRewritingExpressionVisitor.cs:line 394 at Microsoft.EntityFrameworkCore.Query.Internal.IncludeCompiler.CollectionQueryModelRewritingExpressionVisitor.Rewrite(QueryModel collectionQueryModel, INavigation navigation) in C:\enlistments\Universe\EntityFramework\src\EFCore\Query\Internal\IncludeCompiler.CollectionQueryModelRewritingExpressionVisitor.cs:line 149 at Microsoft.EntityFrameworkCore.Query.Internal.IncludeCompiler.CollectionQueryModelRewritingExpressionVisitor.VisitMethodCall(MethodCallExpression methodCallExpression) in C:\enlistments\Universe\EntityFramework\src\EFCore\Query\Internal\IncludeCompiler.CollectionQueryModelRewritingExpressionVisitor.cs:line 65 at System.Linq.Expressions.MethodCallExpression.Accept(ExpressionVisitor visitor) at System.Linq.Expressions.ExpressionVisitor.Visit(Expression node) at System.Dynamic.Utils.ExpressionVisitorUtils.VisitBlockExpressions(ExpressionVisitor visitor, BlockExpression block) at System.Linq.Expressions.ExpressionVisitor.VisitBlock(BlockExpression node) at System.Linq.Expressions.BlockExpression.Accept(ExpressionVisitor visitor) at System.Linq.Expressions.ExpressionVisitor.Visit(Expression node) at System.Linq.Expressions.ExpressionVisitor.VisitLambda[T](Expression1 node)
at System.Linq.Expressions.Expression1.Accept(ExpressionVisitor visitor) at System.Linq.Expressions.ExpressionVisitor.Visit(Expression node) at System.Dynamic.Utils.ExpressionVisitorUtils.VisitArguments(ExpressionVisitor visitor, IArgumentProvider nodes) at System.Linq.Expressions.ExpressionVisitor.VisitMethodCall(MethodCallExpression node) at Microsoft.EntityFrameworkCore.Query.Internal.IncludeCompiler.CollectionQueryModelRewritingExpressionVisitor.VisitMethodCall(MethodCallExpression methodCallExpression) in C:\enlistments\Universe\EntityFramework\src\EFCore\Query\Internal\IncludeCompiler.CollectionQueryModelRewritingExpressionVisitor.cs:line 83 at System.Linq.Expressions.MethodCallExpression.Accept(ExpressionVisitor visitor) at System.Linq.Expressions.ExpressionVisitor.Visit(Expression node) at Remotion.Linq.Clauses.SelectClause.TransformExpressions(Func2 transformation)
at Remotion.Linq.QueryModel.TransformExpressions(Func2 transformation) at Microsoft.EntityFrameworkCore.Query.Internal.IncludeCompiler.RewriteCollectionQueries(QueryModel queryModel) in C:\enlistments\Universe\EntityFramework\src\EFCore\Query\Internal\IncludeCompiler.cs:line 114 at Microsoft.EntityFrameworkCore.Query.Internal.IncludeCompiler.RewriteCollectionQueries() in C:\enlistments\Universe\EntityFramework\src\EFCore\Query\Internal\IncludeCompiler.cs:line 101 at Microsoft.EntityFrameworkCore.Query.EntityQueryModelVisitor.OptimizeQueryModel(QueryModel queryModel, Boolean asyncQuery) in C:\enlistments\Universe\EntityFramework\src\EFCore\Query\EntityQueryModelVisitor.cs:line 349 at Microsoft.EntityFrameworkCore.Query.RelationalQueryModelVisitor.OptimizeQueryModel(QueryModel queryModel, Boolean asyncQuery) in C:\enlistments\Universe\EntityFramework\src\EFCore.Relational\Query\RelationalQueryModelVisitor.cs:line 1345 at Microsoft.EntityFrameworkCore.Query.EntityQueryModelVisitor.CreateQueryExecutor[TResult](QueryModel queryModel) in C:\enlistments\Universe\EntityFramework\src\EFCore\Query\EntityQueryModelVisitor.cs:line 170 at Microsoft.EntityFrameworkCore.Storage.Database.CompileQuery[TResult](QueryModel queryModel) in C:\enlistments\Universe\EntityFramework\src\EFCore\Storage\Database.cs:line 70 --- End of stack trace from previous location where exception was thrown --- at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.CompileQueryCore[TResult](Expression query, IQueryModelGenerator queryModelGenerator, IDatabase database, IDiagnosticsLogger1 logger, Type contextType) in C:\enlistments\Universe\EntityFramework\src\EFCore\Query\Internal\QueryCompiler.cs:line 151
at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.<>c__DisplayClass13_01.<Execute>b__0() in C:\enlistments\Universe\EntityFramework\src\EFCore\Query\Internal\QueryCompiler.cs:line 91 at Microsoft.EntityFrameworkCore.Query.Internal.CompiledQueryCache.GetOrAddQueryCore[TFunc](Object cacheKey, Func1 compiler) in C:\enlistments\Universe\EntityFramework\src\EFCore\Query\Internal\CompiledQueryCache.cs:line 67
at Microsoft.EntityFrameworkCore.Query.Internal.CompiledQueryCache.GetOrAddQuery[TResult](Object cacheKey, Func1 compiler) in C:\enlistments\Universe\EntityFramework\src\EFCore\Query\Internal\CompiledQueryCache.cs:line 44 at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.Execute[TResult](Expression query) in C:\enlistments\Universe\EntityFramework\src\EFCore\Query\Internal\QueryCompiler.cs:line 87 at Microsoft.EntityFrameworkCore.Query.Internal.EntityQueryProvider.Execute[TResult](Expression expression) in C:\enlistments\Universe\EntityFramework\src\EFCore\Query\Internal\EntityQueryProvider.cs:line 62 at Remotion.Linq.QueryableBase1.GetEnumerator()
at System.Collections.Generic.List1.AddEnumerable(IEnumerable1 enumerable)
at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
at Microsoft.EntityFrameworkCore.Query.SimpleQuerySqlServerTest.Include_before_Concat() in C:\enlistments\Universe\EntityFramework\test\EFCore.SqlServer.FunctionalTests\Query\SimpleQuerySqlServerTest.JoinGroupJoin.cs:line 555

@ajcvickers ajcvickers added this to the 3.0.0 milestone Sep 5, 2018
@smitpatel smitpatel assigned maumar and unassigned smitpatel Jun 6, 2019
@maumar maumar assigned roji and unassigned maumar Jun 20, 2019
@maumar
Copy link
Contributor

maumar commented Jun 20, 2019

assigning to @roji since he is implementing set operations

roji added a commit to roji/efcore that referenced this issue Jun 25, 2019
* Include/nav rewriting is now supported.
* We now push down to subquery when OrderBy, Take or Skip are applied to set operations, to avoid using the hack where ColumnExpression with no table alias was used. dotnet#16244 was opened to track for post-3.0.
* Added missing support for union over subselect projection mappings.
* Added Other type to SetOperationType so that providers can define extra set operations (e.g. PostgreSQL `INTERSECT ALL`, `EXCEPT ALL`).

Completes dotnet#6812
Fixes dotnet#13196
Fixes dotnet#16065
Fixes dotnet#16165
roji added a commit that referenced this issue Jun 25, 2019
* Include/nav rewriting is now supported.
* We now push down to subquery when OrderBy, Take or Skip are applied to set operations, to avoid using the hack where ColumnExpression with no table alias was used. #16244 was opened to track for post-3.0.
* Added missing support for union over subselect projection mappings.
* Added Other type to SetOperationType so that providers can define extra set operations (e.g. PostgreSQL `INTERSECT ALL`, `EXCEPT ALL`).

Completes #6812
Fixes #13196
Fixes #16065
Fixes #16165
@roji
Copy link
Member

roji commented Jun 25, 2019

This actually works in the new implementation (#16249) - even with an include only on one operand of the set operation.

roji added a commit to roji/efcore that referenced this issue Jun 26, 2019
* Include/nav rewriting is now supported.
* We now push down to subquery when OrderBy, Take or Skip are applied to set operations, to avoid using the hack where ColumnExpression with no table alias was used. dotnet#16244 was opened to track for post-3.0.
* Added missing support for union over subselect projection mappings.
* Added Other type to SetOperationType so that providers can define extra set operations (e.g. PostgreSQL `INTERSECT ALL`, `EXCEPT ALL`).

Completes dotnet#6812
Fixes dotnet#13196
Fixes dotnet#16065
Fixes dotnet#16165
roji added a commit to roji/efcore that referenced this issue Jun 27, 2019
* Include/nav rewriting is now supported.
* We now push down to subquery when OrderBy, Take or Skip are applied to set operations, to avoid using the hack where ColumnExpression with no table alias was used. dotnet#16244 was opened to track for post-3.0.
* Added missing support for union over subselect projection mappings.
* Added Other type to SetOperationType so that providers can define extra set operations (e.g. PostgreSQL `INTERSECT ALL`, `EXCEPT ALL`).

Completes dotnet#6812
Fixes dotnet#13196
Fixes dotnet#16065
Fixes dotnet#16165
roji added a commit that referenced this issue Jun 27, 2019
* Include/nav rewriting is now supported.
* We now push down to subquery when OrderBy, Take or Skip are applied to set operations, to avoid using the hack where ColumnExpression with no table alias was used. #16244 was opened to track for post-3.0.
* Added missing support for union over subselect projection mappings.
* Added Other type to SetOperationType so that providers can define extra set operations (e.g. PostgreSQL `INTERSECT ALL`, `EXCEPT ALL`).

Completes #6812
Fixes #13196
Fixes #16065
Fixes #16165
roji added a commit to roji/efcore that referenced this issue Jun 27, 2019
* Include/nav rewriting is now supported.
* We now push down to subquery when OrderBy, Take or Skip are applied to set operations, to avoid using the hack where ColumnExpression with no table alias was used. dotnet#16244 was opened to track for post-3.0.
* Added missing support for union over subselect projection mappings.
* Added Other type to SetOperationType so that providers can define extra set operations (e.g. PostgreSQL `INTERSECT ALL`, `EXCEPT ALL`).

Completes dotnet#6812
Fixes dotnet#13196
Fixes dotnet#16065
Fixes dotnet#16165
roji added a commit that referenced this issue Jun 27, 2019
* Include/nav rewriting is now supported.
* We now push down to subquery when OrderBy, Take or Skip are applied to set operations, to avoid using the hack where ColumnExpression with no table alias was used. #16244 was opened to track for post-3.0.
* Added missing support for union over subselect projection mappings.
* Added Other type to SetOperationType so that providers can define extra set operations (e.g. PostgreSQL `INTERSECT ALL`, `EXCEPT ALL`).

Completes #6812
Fixes #13196
Fixes #16065
Fixes #16165
@ajcvickers ajcvickers added the closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. label Jun 27, 2019
roji added a commit that referenced this issue Jun 28, 2019
* Include/nav rewriting is now supported.
* We now push down to subquery when OrderBy, Take or Skip are applied to set operations, to avoid using the hack where ColumnExpression with no table alias was used. #16244 was opened to track for post-3.0.
* Added missing support for union over subselect projection mappings.
* Added Other type to SetOperationType so that providers can define extra set operations (e.g. PostgreSQL `INTERSECT ALL`, `EXCEPT ALL`).

Completes #6812
Fixes #13196
Fixes #16065
Fixes #16165
roji added a commit that referenced this issue Jun 28, 2019
roji added a commit that referenced this issue Jun 28, 2019
@ajcvickers ajcvickers reopened this Jun 28, 2019
roji added a commit that referenced this issue Jul 1, 2019
roji added a commit that referenced this issue Jul 1, 2019
@ajcvickers ajcvickers modified the milestones: 3.0.0, 3.0.0-preview7 Jul 2, 2019
@ajcvickers ajcvickers modified the milestones: 3.0.0-preview7, 3.0.0 Jul 2, 2019
@ajcvickers ajcvickers modified the milestones: 3.0.0, 3.0.0-preview8 Jul 29, 2019
@ajcvickers ajcvickers modified the milestones: 3.0.0-preview8, 3.0.0 Nov 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. type-bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants