You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
ToPageAsync() (QueryHelpers.EnsureOrderPropsAreSelected) attempts to select Order properties that it should not #8262
Property 'System.String Name2' is not defined for type 'HotChocolateIssueReproduction.Types.SpeakerDto' (Parameter 'property')
The same exception is also thrown by the speakers2 field, which uses [UsePaging] instead of [UseConnection].
What is expected?
When OrderBy expressions exist in the Selector, they should not be automatically selected by QueryHelpers.EnsureOrderPropsAreSelected();
What is actually happening?
The following expression contains an OrderBy that causes QueryHelpers.EnsureOrderPropsAreSelected to attempt to select OtherProperty, which does not exist on the Dto.
e =>newDto{Id=e.Id,NotWorking=e.ListOfObjects.OrderByDescending(l =>l.OtherProperty).FirstOrDefault()});
Relevant log output
message: Property 'System.String Name2' is not defined fortype'HotChocolateIssueReproduction.Types.SpeakerDto' (Parameter 'property')
at System.Linq.Expressions.Expression.Property(Expression expression, PropertyInfo property)
at GreenDonut.Data.Expressions.QueryHelpers.AddPropertiesVisitorRewriter.VisitMemberInit(MemberInitExpression node)
at GreenDonut.Data.Expressions.QueryHelpers.AddPropertiesInSelector[T](Expression`1 selector, List`1 properties)
at GreenDonut.Data.Expressions.QueryHelpers.EnsureOrderPropsAreSelected[T](IQueryable`1 query) at GreenDonut.Data.PagingQueryableExtensions.ToPageAsync[T](IQueryable`1 source, PagingArguments arguments, Boolean includeTotalCount, CancellationToken cancellationToken) at GreenDonut.Data.PagingQueryableExtensions.ToPageAsync[T](IQueryable`1 source, PagingArguments arguments, CancellationToken cancellationToken)
Additional context
Issue initially submitted for version 15.1.3 but still reproduces in 16.0.14-p.1.
I had already started digging into this yesterday, so I went ahead and opened #9840. Feel free to build on it directly or close it if you have a different approach in mind.
Activity
tomachristian commentedon Sep 5, 2025
Having the same exact issue.
Tommsy64 commentedon Jun 3, 2026
Coming back to this a year later: It still reproduces on the latest preview,
16.0.14-p.1, and I've updated the issue body and reproduction to match.I've also simplified the reproduction so it no longer needs a live database.
michaelstaib commentedon Jun 3, 2026
Let me have a look at this one.
Fix paging failure when a selector contains a nested OrderBy (ChilliC…
Fix paging failure when a query lambda contains a nested OrderBy (Chi…
Fix paging failure when a query lambda contains a nested OrderBy (Chi…
Share the lambda-skip invariant via a QueryChainVisitor base class (C…
Tommsy64 commentedon Jun 3, 2026
I had already started digging into this yesterday, so I went ahead and opened #9840. Feel free to build on it directly or close it if you have a different approach in mind.
Fix #8262 ToPageAsync() attempting to select invalid properties (#9840)