Skip to content

Query: compilation error (dangling qsre) for query with SelectMany, order by and include collection #12794

@maumar

Description

@maumar

Query:

var query = ctx.LevelOne.OrderBy(l1 => l1.Id).SelectMany(l1 => l1.OneToMany_Optional).Include(l2 => l2.OneToMany_Optional);
var result = query.ToList();

query plan:

(QueryContext queryContext) => IEnumerable<Level2> _InterceptExceptions(
|__ source: IEnumerable<Level2> _Select(
|   |__ source: IEnumerable<TransparentIdentifier<ValueBuffer, Level2>> _Join(
|   |   |__ outer: IOrderedEnumerable<ValueBuffer> _ThenBy(
|   |   |   |__ source: IOrderedEnumerable<ValueBuffer> _OrderBy(
|   |   |   |   |__ source: IEnumerable<ValueBuffer> _ShapedQuery(
|   |   |   |   |   |__ queryContext: queryContext, 
|   |   |   |   |   |__ shaperCommandContext: SelectExpression: 
|   |   |   |   |   |       SELECT [l1].[Id]
|   |   |   |   |   |       FROM [LevelOne] AS [l1], 
|   |   |   |   |   |__ shaper: ValueBufferShaper), 
|   |   |   |   |__ expression: (ValueBuffer l1) => int TryReadValue(l1, 0, Level1.Id), 
|   |   |   |   |__ orderingDirection: Asc), 
|   |   |   |__ expression: (ValueBuffer l1) => 
|   |   |   |   {
|   |   |   |       __caller =  ---> [l1.OneToMany_Optional] <--- 
|   |   |   |       __result = default(Nullable<int>)
|   |   |   |       __caller != default(Level2) ? __result = Nullable<int> GetValue(
|   |   |   |       |__ queryContext: queryContext, 
|   |   |   |       |__ entity: __caller, 
|   |   |   |       |__ property: Level2.Id) : default(void)
|   |   |   |       return __result
|   |   |   |   }, 
|   |   |   |__ orderingDirection: Asc), 
|   |   |__ inner: IEnumerable<Level2> _ShapedQuery(
|   |   |   |__ queryContext: queryContext, 
|   |   |   |__ shaperCommandContext: SelectExpression: 
|   |   |   |       SELECT [l1.OneToMany_Optional].[Id], [l1.OneToMany_Optional].[Date], [l1.OneToMany_Optional].[Level1_Optional_Id], [l1.OneToMany_Optional].[Level1_Required_Id], [l1.OneToMany_Optional].[Name], [l1.OneToMany_Optional].[OneToMany_Optional_InverseId], [l1.OneToMany_Optional].[OneToMany_Optional_Self_InverseId], [l1.OneToMany_Optional].[OneToMany_Required_InverseId], [l1.OneToMany_Optional].[OneToMany_Required_Self_InverseId], [l1.OneToMany_Optional].[OneToOne_Optional_PK_InverseId], [l1.OneToMany_Optional].[OneToOne_Optional_SelfId]
|   |   |   |       FROM [LevelTwo] AS [l1.OneToMany_Optional], 
|   |   |   |__ shaper: BufferedEntityShaper<Level2>), 
|   |   |__ outerKeySelector: (ValueBuffer l1) => (Nullable<int>)int TryReadValue(l1, 0, Level1.Id), 
|   |   |__ innerKeySelector: (Level2 l1.OneToMany_Optional) => Nullable<int> GetValue(
|   |   |   |__ queryContext: queryContext, 
|   |   |   |__ entity: l1.OneToMany_Optional, 
|   |   |   |__ property: Level2.OneToMany_Optional_InverseId), 
|   |   |__ resultSelector: (ValueBuffer l1 | Level2 l1.OneToMany_Optional) => TransparentIdentifier<ValueBuffer, Level2> CreateTransparentIdentifier(
|   |       |__ outer: l1, 
|   |       |__ inner: l1.OneToMany_Optional)), 
|   |__ selector: (TransparentIdentifier<ValueBuffer, Level2> t0) => Level2 _Include(
|       |__ queryContext: queryContext, 
|       |__ entity: t0.Inner, 
|       |__ included: new object[]{ }, 
|       |__ fixup: (QueryContext queryContext | Level2 entity | object[] included) => 
|           {
|               return void queryContext.QueryBuffer.IncludeCollection(
|               |__ includeId: 0, 
|               |__ navigation: Level2.OneToMany_Optional, 
|               |__ inverseNavigation: Level3.OneToMany_Optional_Inverse, 
|               |__ targetEntityType: EntityType: Level3, 
|               |__ clrCollectionAccessor: ClrICollectionAccessor<Level2, ICollection<Level3>, Level3>, 
|               |__ inverseClrPropertySetter: ClrPropertySetter<Level3, Level2>, 
|               |__ tracking: False, 
|               |__ instance: entity, 
|               |__ valuesFactory: () => IEnumerable<Level3> _ShapedQuery(
|               |   |__ queryContext: queryContext, 
|               |   |__ shaperCommandContext: SelectExpression: 
|               |   |       SELECT [l1.OneToMany_Optional.OneToMany_Optional].[Id], [l1.OneToMany_Optional.OneToMany_Optional].[Level2_Optional_Id], [l1.OneToMany_Optional.OneToMany_Optional].[Level2_Required_Id], [l1.OneToMany_Optional.OneToMany_Optional].[Name], [l1.OneToMany_Optional.OneToMany_Optional].[OneToMany_Optional_InverseId], [l1.OneToMany_Optional.OneToMany_Optional].[OneToMany_Optional_Self_InverseId], [l1.OneToMany_Optional.OneToMany_Optional].[OneToMany_Required_InverseId], [l1.OneToMany_Optional.OneToMany_Optional].[OneToMany_Required_Self_InverseId], [l1.OneToMany_Optional.OneToMany_Optional].[OneToOne_Optional_PK_InverseId], [l1.OneToMany_Optional.OneToMany_Optional].[OneToOne_Optional_SelfId]
|               |   |       FROM [LevelThree] AS [l1.OneToMany_Optional.OneToMany_Optional]
|               |   |       INNER JOIN (
|               |   |           SELECT DISTINCT [l1.OneToMany_Optional0].[Id], [l10].[Id] AS [Id0]
|               |   |           FROM [LevelOne] AS [l10]
|               |   |           INNER JOIN [LevelTwo] AS [l1.OneToMany_Optional0] ON [l10].[Id] = [l1.OneToMany_Optional0].[OneToMany_Optional_InverseId]
|               |   |       ) AS [t] ON [l1.OneToMany_Optional.OneToMany_Optional].[OneToMany_Optional_InverseId] = [t].[Id]
|               |   |       ORDER BY [t].[Id0], [t].[Id], 
|               |   |__ shaper: BufferedEntityShaper<Level3>), 
|               |__ joinPredicate: default(Func<Level2, Level3, bool>))
|           })), 
|__ contextType: TestModels.ComplexNavigationsModel.ComplexNavigationsContext, 
|__ logger: DiagnosticsLogger<Query>, 
|__ queryContext: Unhandled parameter: queryContext)

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