Skip to content

Query: compilation error for queries with Concat on two entities and scalar projection on top #9007

@maumar

Description

@maumar

query:

context.Gears.Concat(context.Gears).Select(g => g.Nickname);

exception:

The input sequence must have items of type 'Microsoft.EntityFrameworkCore.TestModels.GearsOfWarModel.Gear', but it has items of type 'System.String'.
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()
	C:\git\EntityFramework\src\EFCore\Query\EntityQueryModelVisitor.cs(570,0): at Microsoft.EntityFrameworkCore.Query.EntityQueryModelVisitor.TrackResults(QueryModel queryModel)
	C:\git\EntityFramework\src\EFCore\Query\EntityQueryModelVisitor.cs(287,0): at Microsoft.EntityFrameworkCore.Query.EntityQueryModelVisitor.OptimizeQueryModel(QueryModel queryModel, Boolean asyncQuery)
	C:\git\EntityFramework\src\EFCore.Relational\Query\RelationalQueryModelVisitor.cs(1157,0): at Microsoft.EntityFrameworkCore.Query.RelationalQueryModelVisitor.OptimizeQueryModel(QueryModel queryModel, Boolean asyncQuery)
	C:\git\EntityFramework\src\EFCore\Query\EntityQueryModelVisitor.cs(171,0): at Microsoft.EntityFrameworkCore.Query.EntityQueryModelVisitor.CreateQueryExecutor[TResult](QueryModel queryModel)
	C:\git\EntityFramework\src\EFCore\Storage\Database.cs(70,0): at Microsoft.EntityFrameworkCore.Storage.Database.CompileQuery[TResult](QueryModel queryModel)
	--- End of stack trace from previous location where exception was thrown ---
	at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
	C:\git\EntityFramework\src\EFCore\Query\Internal\QueryCompiler.cs(164,0): at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.CompileQueryCore[TResult](Expression query, INodeTypeProvider nodeTypeProvider, IDatabase database, IDiagnosticsLogger`1 logger, Type contextType)
	C:\git\EntityFramework\src\EFCore\Query\Internal\QueryCompiler.cs(103,0): at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.<>c__DisplayClass15_0`1.<Execute>b__0()
	C:\git\EntityFramework\src\EFCore\Query\Internal\CompiledQueryCache.cs(69,0): at Microsoft.EntityFrameworkCore.Query.Internal.CompiledQueryCache.GetOrAddQueryCore[TFunc](Object cacheKey, Func`1 compiler)
	C:\git\EntityFramework\src\EFCore\Query\Internal\CompiledQueryCache.cs(44,0): at Microsoft.EntityFrameworkCore.Query.Internal.CompiledQueryCache.GetOrAddQuery[TResult](Object cacheKey, Func`1 compiler)
	C:\git\EntityFramework\src\EFCore\Query\Internal\QueryCompiler.cs(99,0): at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.Execute[TResult](Expression query)
	C:\git\EntityFramework\src\EFCore\Query\Internal\EntityQueryProvider.cs(62,0): at Microsoft.EntityFrameworkCore.Query.Internal.EntityQueryProvider.Execute[TResult](Expression expression)
	at Remotion.Linq.QueryableBase`1.GetEnumerator()
	at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)

Looks like we are creating invalid QM that relinq can't quite handle when we ask for it's OutputDataInfo during tracking

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No fields configured for Bug.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions