Skip to content

Include before Concat throws on nav rewrite #13196

Description

@AndriySvyryd
[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

Activity

  1. added this to the 3.0.0 milestone on Sep 5, 2018
  2. assigned and unassigned on Jun 20, 2019
  3. maumar commented on Jun 20, 2019

    @maumar
    Contributor

    assigning to @roji since he is implementing set operations

  4. added 2 commits that reference this issue on Jun 25, 2019
    6004e53
    68ae5a8
  5. roji commented on Jun 25, 2019

    @roji
    Member

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

  6. added 4 commits that reference this issue on Jun 26, 2019
    0421853
    e790f0d
    b2b7e5b
    117509e
  7. 6 remaining items

  8. added a commit that references this issue on Jul 1, 2019
    686d56d
  9. added a commit that references this issue on Jul 1, 2019
    95ef38d
  10. modified the milestones: 3.0.0, on Jul 2, 2019
  11. modified the milestones: 3.0.0, on Jul 29, 2019
  12. modified the milestones: , 3.0.0 on Nov 11, 2019
  13. added theissue type on Jun 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions