Datagrid sub properties column filter fails for OData #1933

Closed
opened 2026-01-29 18:15:48 +00:00 by claunia · 3 comments
Owner

Originally created by @RaHorusFreak on GitHub (Dec 17, 2025).

Describe the bug
When implementing the example case: "DataGrid Sub Properties Column Filter", the arguments produced for "LoadDataArgs.Filter" cause errors when used via OData againts a DBContext.

To Reproduce
Steps to reproduce the behavior:

  1. Implement 'https://blazor.radzen.com/datagrid-sub-properties-filter'
  2. After, try to use the produced filter by implementing 'https://blazor.radzen.com/datagrid-odata'
  3. See error (related to the sub properties column): System.Linq.Dynamic.Core.Exceptions.ParseException: '')' or ',' expected'

Expected behavior
The produced filter (LoadDataArgs.Filter) must work for both Linq and OData cases.

Desktop:

  • OS: Win 11 24H2
  • Browser: Edge

Additional context
OData case fails because the produced filter is in the form:
x => x.Collection.Any(x => ((x ?? "").ToLower() ?? "").Contains("test"))
The duplication of the identifier "x" within the Any is the trigger for the error.
If we replace the expression with: x => x.Collection.Any(x1 => ((x1 ?? "").ToLower() ?? "").Contains("test")), it works correctly.

Originally created by @RaHorusFreak on GitHub (Dec 17, 2025). **Describe the bug** When implementing the example case: "DataGrid Sub Properties Column Filter", the arguments produced for "LoadDataArgs.Filter" cause errors when used via OData againts a DBContext. **To Reproduce** Steps to reproduce the behavior: 1. Implement 'https://blazor.radzen.com/datagrid-sub-properties-filter' 2. After, try to use the produced filter by implementing 'https://blazor.radzen.com/datagrid-odata' 3. See error (related to the sub properties column): System.Linq.Dynamic.Core.Exceptions.ParseException: '')' or ',' expected' **Expected behavior** The produced filter (LoadDataArgs.Filter) must work for both Linq and OData cases. **Desktop:** - OS: Win 11 24H2 - Browser: Edge **Additional context** OData case fails because the produced filter is in the form: `x => x.Collection.Any(x => ((x ?? "").ToLower() ?? "").Contains("test"))` The duplication of the identifier "x" within the Any is the trigger for the error. If we replace the expression with: `x => x.Collection.Any(x1 => ((x1 ?? "").ToLower() ?? "").Contains("test"))`, it works correctly.
Author
Owner

@enchev commented on GitHub (Dec 18, 2025):

You've missed the most important part of the OData demo - to tell the DataGrid to produce OData compatible filter/sort expressions you need to bind to ODataEnumerable. This demo might help you as well with more complex scenarious like sub properties:
https://blazor.radzen.com/datafilter-odata?theme=material3

@enchev commented on GitHub (Dec 18, 2025): You've missed the most important part of the OData demo - to tell the DataGrid to produce OData compatible filter/sort expressions you need to bind to ODataEnumerable. This demo might help you as well with more complex scenarious like sub properties: https://blazor.radzen.com/datafilter-odata?theme=material3
Author
Owner

@RaHorusFreak commented on GitHub (Dec 18, 2025):

Hello @enchev , thank you very much for your quick response.

In my case, I don't use RadzenDataFilter to filter the data; instead, I use the one provided natively by RadzenDataGrid. In this case, the filter acts on a property that contains a collection of elements (IEnumerable). I do the binding in a way equivalent to the example shown in 'https://blazor.radzen.com/datagrid-sub-properties-filter'.

<RadzenDataGridColumn Property="@nameof(WarningItemDto.Regions)" Title="Regiões" Type="typeof(ISet<string>)" Width="235px" Sortable="@false">
    <Template>
        @(string.Join(", ", context.Regions))
    </Template>
</RadzenDataGridColumn>

Therefore, I get the filter directly from LoadDataArgs in the LoadData event. When examining LoadDataArgs.Filter in sample cases, values such as the following occur:

x => x.Regions.Any(x => ((x ?? "").ToLower() ?? "").Contains("Place"))

Here, as you can see, there is a duplication in the declaration of the parameter "x" (one general, and another within the Any method), which causes System.Linq.Dynamic.Core to interpret the filter incorrectly from a syntactical standpoint, producing the error: "System.Linq.Dynamic.Core.Exceptions.ParseException: '')' or ',' expected".
Replacing the problematic filter section with

x => x.Regions.Any(x1 => ((x1 ?? "").ToLower() ?? "").Contains("Place"))

(the second parameter x is replaced by x1) makes it work correctly. So we are facing a problem with the syntax generated for the LoadDataArgs filter when interacting with a column that represents a collection of items.

@RaHorusFreak commented on GitHub (Dec 18, 2025): Hello @enchev , thank you very much for your quick response. In my case, I don't use RadzenDataFilter to filter the data; instead, I use the one provided natively by RadzenDataGrid. In this case, the filter acts on a property that contains a collection of elements (IEnumerable). I do the binding in a way equivalent to the example shown in 'https://blazor.radzen.com/datagrid-sub-properties-filter'. ``` <RadzenDataGridColumn Property="@nameof(WarningItemDto.Regions)" Title="Regiões" Type="typeof(ISet<string>)" Width="235px" Sortable="@false"> <Template> @(string.Join(", ", context.Regions)) </Template> </RadzenDataGridColumn> ``` Therefore, I get the filter directly from LoadDataArgs in the LoadData event. When examining LoadDataArgs.Filter in sample cases, values such as the following occur: `x => x.Regions.Any(x => ((x ?? "").ToLower() ?? "").Contains("Place"))` Here, as you can see, there is a duplication in the declaration of the parameter "x" (one general, and another within the Any method), which causes System.Linq.Dynamic.Core to interpret the filter incorrectly from a syntactical standpoint, producing the error: "System.Linq.Dynamic.Core.Exceptions.ParseException: '')' or ',' expected". Replacing the problematic filter section with `x => x.Regions.Any(x1 => ((x1 ?? "").ToLower() ?? "").Contains("Place"))` (the second parameter x is replaced by x1) makes it work correctly. So we are facing a problem with the syntax generated for the LoadDataArgs filter when interacting with a column that represents a collection of items.
Author
Owner

@RaHorusFreak commented on GitHub (Dec 19, 2025):

Please consider reopening the issue as it's not solved. I have some workarounds that can help other devs who are facing the same problem.

@RaHorusFreak commented on GitHub (Dec 19, 2025): Please consider reopening the issue as it's not solved. I have some workarounds that can help other devs who are facing the same problem.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/radzen-blazor#1933