Skip to content

Query: compilation error for queries with collection include and concat #12889

@maumar

Description

@maumar

query:

                var query = ctx.Gears.Include(g => g.Weapons).Concat(ctx.Gears);
                var result = query.ToList();

exception:

The input sequence must have items of type 'Microsoft.EntityFrameworkCore.TestModels.GearsOfWarModel.Gear', 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 Remotion.Linq.QueryModel.<GetOutputDataInfo>b__0(IStreamedDataInfo current, ResultOperatorBase resultOperator)
	at System.Linq.Enumerable.Aggregate[TSource,TAccumulate](IEnumerable`1 source, TAccumulate seed, Func`3 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, ICollection`1 subQueryProjection)
	at Microsoft.EntityFrameworkCore.Query.Internal.IncludeCompiler.CollectionQueryModelRewritingExpressionVisitor.Rewrite(QueryModel collectionQueryModel, INavigation navigation)
	at Microsoft.EntityFrameworkCore.Query.Internal.IncludeCompiler.CollectionQueryModelRewritingExpressionVisitor.VisitMethodCall(MethodCallExpression methodCallExpression)
	at System.Linq.Expressions.MethodCallExpression.Accept(ExpressionVisitor visitor)
	at System.Linq.Expressions.ExpressionVisitor.Visit(Expression node)
	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](Expression`1 node)
	at System.Linq.Expressions.Expression`1.Accept(ExpressionVisitor visitor)
	at System.Linq.Expressions.ExpressionVisitor.Visit(Expression node)
	at System.Linq.Expressions.ExpressionVisitor.VisitArguments(IArgumentProvider nodes)
	at System.Linq.Expressions.ExpressionVisitor.VisitMethodCall(MethodCallExpression node)
	at Microsoft.EntityFrameworkCore.Query.Internal.IncludeCompiler.CollectionQueryModelRewritingExpressionVisitor.VisitMethodCall(MethodCallExpression methodCallExpression)
	at System.Linq.Expressions.MethodCallExpression.Accept(ExpressionVisitor visitor)
	at System.Linq.Expressions.ExpressionVisitor.Visit(Expression node)
	at Remotion.Linq.Clauses.SelectClause.TransformExpressions(Func`2 transformation)
	at Remotion.Linq.QueryModel.TransformExpressions(Func`2 transformation)
	at Microsoft.EntityFrameworkCore.Query.Internal.IncludeCompiler.RewriteCollectionQueries(QueryModel queryModel)
	at Microsoft.EntityFrameworkCore.Query.Internal.IncludeCompiler.RewriteCollectionQueries()
	at Microsoft.EntityFrameworkCore.Query.EntityQueryModelVisitor.OptimizeQueryModel(QueryModel queryModel, Boolean asyncQuery)
	at Microsoft.EntityFrameworkCore.Query.RelationalQueryModelVisitor.OptimizeQueryModel(QueryModel queryModel, Boolean asyncQuery)
	at Microsoft.EntityFrameworkCore.Query.EntityQueryModelVisitor.CreateQueryExecutor[TResult](QueryModel queryModel)
	at Microsoft.EntityFrameworkCore.Storage.Database.CompileQuery[TResult](QueryModel queryModel)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No fields configured for Bug.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions