-
Notifications
You must be signed in to change notification settings - Fork 10.4k
Fix QuickGrid nullable property sorting by handling UnaryExpression in ToPropertyName #62602
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…n ToPropertyName Co-authored-by: javiercn <6995051+javiercn@users.noreply.github.com>
src/Components/QuickGrid/Microsoft.AspNetCore.Components.QuickGrid/src/Columns/GridSort.cs
Show resolved
Hide resolved
…pertyName method Co-authored-by: javiercn <6995051+javiercn@users.noreply.github.com>
Co-authored-by: javiercn <6995051+javiercn@users.noreply.github.com>
Co-authored-by: javiercn <6995051+javiercn@users.noreply.github.com>
@copilot D:\a_work\1\s\src\Components\Components.slnf references a project not in AspNetCore.slnx: src\Components\QuickGrid\Microsoft.AspNetCore.Components.QuickGrid\test\Microsoft.AspNetCore.Components.QuickGrid.Tests.csproj |
Co-authored-by: javiercn <6995051+javiercn@users.noreply.github.com>
Fixed by adding the QuickGrid test project to the main AspNetCore.slnx solution file. The test project is now properly included in both Components.slnf and AspNetCore.slnx. Commit: ca4430e |
@copilot |
…ructure for QuickGrid tests Co-authored-by: javiercn <6995051+javiercn@users.noreply.github.com>
Fixed by adding |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some refactor related suggestions.
src/Components/QuickGrid/Microsoft.AspNetCore.Components.QuickGrid/test/GridSortTest.cs
Outdated
Show resolved
Hide resolved
src/Components/QuickGrid/Microsoft.AspNetCore.Components.QuickGrid/test/GridSortTest.cs
Outdated
Show resolved
Hide resolved
....AspNetCore.Components.QuickGrid/test/Microsoft.AspNetCore.Components.QuickGrid.Tests.csproj
Outdated
Show resolved
Hide resolved
src/Components/QuickGrid/Microsoft.AspNetCore.Components.QuickGrid/test/GridSortTest.cs
Show resolved
Hide resolved
…Grid/test/Microsoft.AspNetCore.Components.QuickGrid.Tests.csproj Co-authored-by: Arnab Roy Chowdhury <arnab.roy.chowdhury.developer@gmail.com>
…Grid/test/GridSortTest.cs Co-authored-by: Arnab Roy Chowdhury <arnab.roy.chowdhury.developer@gmail.com>
…Grid/test/GridSortTest.cs Co-authored-by: Arnab Roy Chowdhury <arnab.roy.chowdhury.developer@gmail.com>
The QuickGrid component was failing when attempting to sort by nullable properties (like
DateTime?
) with the error:This occurred because the
ToPropertyName
method inGridSort.cs
only handledMemberExpression
but notUnaryExpression
. When nullable properties are used in expressions that undergo implicit conversions (such asDateTime?
toobject
), C# generates aUnaryExpression
wrapping theMemberExpression
.Example of the issue:
Solution:
Updated the
ToPropertyName
method to handleUnaryExpression
by unwrapping it to get the underlyingMemberExpression
, following the same pattern used inModelBindingHelper.GetPropertyName
.The fix adds a check for
UnaryExpression
withConvert
orConvertChecked
node types and unwraps them before proceeding with the existing logic:This change maintains full backward compatibility while enabling sorting on nullable properties.
Fixes #62582.
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.