Skip to content
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

Handle nullable date type in queryable extension. #1812

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

tale80
Copy link

@tale80 tale80 commented Nov 26, 2024

Added a check to handle properties of nullable date types by accessing their Value property when filtering. This ensures that the filtering logic works correctly with nullable dates.

This PR correct an incorrect request built by the component if the filter need to be applied on a Nullable or Nullable in database

Added a check to handle properties of nullable date types by accessing their `Value` property when filtering. This ensures that the filtering logic works correctly with nullable dates.
@enchev
Copy link
Collaborator

enchev commented Nov 26, 2024

OrderDate in this demo is nullable, can you clarify what is fixing this request?
image

@tale80
Copy link
Author

tale80 commented Nov 26, 2024

@enchev it's because you're currently executing it in IQueryable only in the view.
It can work only if you have a small dataset and provide all data to the filter component. In real world with more data, the request must be executed on server side, and probably on the DB directly for most developers.

If you get your request with ToFilterString, send it to the server and request in DB (for example with DynamicLinq), you will get this error on nullable DateTime/DateTimeOffset (maybe true for others nullable type, I haven't check on all field type for now) :

 System.InvalidOperationException: The binary operator Equal is not defined for the types 'System.Nullable`1[System.DateTimeOffset]' and 'System.DateTime'.

Same for all others operator (NotEquals, GreaterThan, LessThan, GreaterThanOrEquals, LessThanOrEquals)

@enchev
Copy link
Collaborator

enchev commented Nov 26, 2024

I'm afraid that without runnable code demonstrating the problem we will unable to test and merge your pull request. Using ToFilterString() in this demo works as expected:

image

image

@tale80
Copy link
Author

tale80 commented Nov 26, 2024

Weird... I will test without the fix on a nullable DateTime?, I have the trouble on a nullable DateTimeOffset, maybe the behavior is different on both

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants