Syncfusion.Blazor.DataOperations.PerformFiltering Does Not Account for Null Values

I am using `Syncfusion.Blazor.DataOperations.PerformFiltering` for my filtering on DataManagerRequest.Where fields provided by the SfGrid.

However, I am encountering an error when the user does not enter anything in for a filtered datetimeoffset column:


When this is applied, I get the following error thrown:

```

System.ArgumentException: Argument types do not match

at ConstantExpression System.Linq.Expressions.Expression.Constant(object value, Type type)

at ValueTuple Syncfusion.Blazor.Data.QueryableExtensions.GetPxExpression(FilterType filterType, Type memberType, object value, bool isCaseSensitive, Expression memExp, Expression bExp)

at Expression Syncfusion.Blazor.Data.QueryableExtensions.Predicate(IQueryable source, object constValue, FilterType filterType, FilterBehavior filterBehaviour, bool isCaseSensitive, Type sourceType, Type memberType, Expression memExp, ParameterExpression paramExpression, string propertyName) x 2

at Expression Syncfusion.Blazor.Data.QueryableOperation.PredicateBuilder(IQueryable dataSource, List whereFilter, string condition, ParameterExpression paramExpression, Type type) x 2

at IQueryable Syncfusion.Blazor.Data.QueryableOperation.PerformFiltering(IQueryable dataSource, List whereFilter, string condition)

at IQueryable Syncfusion.Blazor.DataOperations.PerformFiltering(IQueryable dataSource, List whereFilter, string condition)

at ValueTask> DragonSpark.SyncfusionRendering.Queries.Where.Get(Parameter parameter) in .../Framework/DragonSpark.Syncfusion/Queries/Where.cs:line 20


```

This appears to be due to the fact that the `value` value on the corresponding WhereFilter object for the provided column is null:



For further context the code used to call PerformFiltering may be found here:

https://github.com/DragonSpark/Framework/blob/master/DragonSpark.Syncfusion/Queries/Where.cs#L21

Thank you for any guidance/suggestions you can provide.


10 Replies

SP Sarveswaran Palani Syncfusion Team June 16, 2023 03:52 AM UTC

Hi Mike,

Greetings from Syncfusion support.

From your query, we prepared sample based on your requirement and filtered the datetimeoffset column. But we’re unable to reproduce a reported exception from our end. We have attached sample for your reference. We request you to share the issue reproducible runnable sample or reproduce a reported issue in the provided sample.
It’ll be helpful to validate further at our end and provide solution as earlier as possible from our end.


Regards,
Sarvesh


Attachment: SfBlazorGrid_9935ed31.zip


MI Mike-E June 16, 2023 08:24 AM UTC

Thank you very much for your investigation and providing the sample project, Sarvesh.  Please change your Date column to the following:


```

<GridColumn Field=@nameof(Order.Date) HeaderText="DateTimeOffset" Width="150"

            FilterSettings="@(new FilterSettings { Operator = Operator.GreaterThanOrEqual, Type = Syncfusion.Blazor.Grids.FilterType.Menu })"></GridColumn>

```



PS Prathap Senthil Syncfusion Team June 19, 2023 09:59 AM UTC

Thanks for the update,

Regarding the issue you reported, we recommend checking the nullable value in the DateTimeOffset property within your project. By ensuring that the nullable property is properly handled, you can prevent the issue from occurring. To help you with this, we have included a code snippet below for your reference.

public class Order

    {

        public int OrderID { get; set; }

        public string CustomerID { get; set; }

        public double? Freight { get; set; }

        public DateTimeOffset? Date { get; set; }

    }

 



MI Mike-E June 19, 2023 10:21 AM UTC

Thank you for the suggestion Prathap.  I am a little confused, however, why this is not an issue when I do not set the column `FilterSettings` property directly.  That is, why is it working in the example you provided but not in the one that I provided?

Please note that changing the property in my case would mean changing my EFCore model which would result in a database change.

Thank you for any further context/assistance you can provide.



MI Mike-E June 28, 2023 06:19 PM UTC

Hi Prathap thank you for any update you can provide. This seems like a bug that needs to be addressed. Any consideration is appreciated. 



SP Sarveswaran Palani Syncfusion Team June 29, 2023 01:30 PM UTC

Hi Mike-E,

Sorry for the delay and inconvenience caused.

Mentioned issue reproduced at our end, we’ll currently validating your query at our end. We’ll confirm with development team and provide the bug details within two business days. Until then, we appreciate your patience.

Regards,
Sarvesh



SP Sarveswaran Palani Syncfusion Team July 3, 2023 05:08 PM UTC

Hi Mike-E,


We have considered it as a bug and logged an issue “Exception Occurs While Filtering the DateTimeOffSet Column” for the same. Thank you for taking the time to report this issue and helping us to improve our product. At Syncfusion, we are committed to fix all validated defects (subject to technological feasibility and Product Development Life Cycle) and this fix will be included in our upcoming patch release.


You can now track the current status of your request, review the proposed resolution timeline, and contact us for any further inquiries through this link.


https://www.syncfusion.com/feedback/44937/exception-occurs-while-filtering-the-datetimeoffset-column


Disclaimer: “Inclusion of this solution in the weekly release may change due to other factors including but not limited to QA checks and works reprioritization”


Until then we appreciate your patience.


Regards,

Sarvesh



MI Mike-E July 4, 2023 10:44 AM UTC

Thank you very much for your efforts and collaboration, Sarvesh and team!  Everyone there is doing really great work and I appreciate it greatly.



SG Suganya Gopinath Syncfusion Team July 5, 2023 06:16 AM UTC

Thank you so much:) We will update you on the fix once it is released. 



SP Sarveswaran Palani Syncfusion Team July 20, 2023 07:45 AM UTC

Hi Mike,


We are glad to announce that, we have included the fix for the issue “Exception Occurs While Filtering the DateTimeOffSet Column” in our 22.1.39 release.  So please upgrade to our latest version of the Syncfusion package to resolve the reported issue.


NuGet: https://www.nuget.org/packages/Syncfusion.Blazor.Grid


We thank you for your support and appreciate your patience in waiting for this release. Please get in touch with us if you would require any further assistance. 


Regards,

Sarvesh


Loader.
Up arrow icon