Filter string from DataGrid

I've run into a quite peculiar problem with enums.

Im using Dynamic.Linq to filter a where clause from at DataGrid

This issue occured after upgrading to 7.0.2 as it creates the filter string differently.

In 6.6.3 the string looks like this: it => it.Color == 1
In 7.0.3 the string looks like this: x => (x.Color == (RadzenPlayground.Components.Models.Color)1)

Its trying to typecast the enum. But as its in another project file. it cant find it.
I'd rather avoid a new project reference just for this.

Is there a work around for this? Or is it possible to avoid the type cast part?

1 Like

I’m afraid that there is no way to avoid this.

Just tried to Use the Filtering Option on the Blazor DataGrid Component - LoadData Event | Free UI Components by Radzen and got the site to crash with the same error as desriped


So something is wrong with the typecast for enum filtering

after trying to filter on Job Titel
it seams to be an issue with Enum filtering and and using the LoadDataEvent

No, the case here is different - the query cannot be translated to SQL. If you add ToList() filtering will start working:


I'll update the demo.

1 Like

I've narrowed down the problem.

The error only occurs when placing the enum in a different project than the web project. It happens even tough there is a project ref.

Uploaded the source code here, so you can have a look. Please have a look at the Counter page.

There somehow must be a fix for this :slight_smile:

Since Radzen.Blazor 6.0 we no longer support System.Linq.Dynamic.Core library due to vulnerability issues. All expressions are C# compatible only and in this particular case System.Linq.Dynamic.Core library cannot parse such expression. If you replace System.Linq.Dynamic.Core library with Radzen.Blazor you will be able to filter normally:



Hi again Enchev.

This seemed to work! :slight_smile:

However i noticed this still requires a Using statement to System.Linq.Dynamic.Core howcome?

And how is it possible when the nuget is uninstalled.

Also does the parser have its own nuget? Im using Clean Architecture and im not a fan of having the whole Radzen.Blazor nuget in my persistence layer :slight_smile:

Since in Radzen.Blazor pre 6.0 we relied heavily on System.Linq.Dynamic.Core and to avoid even greater breaking change we've added our own extension methods to the same namespace that are using our own parser. No, the parser is not in different assembly.

Hi again,

Is the the Radzen.ExpressionParser you are refeering to?

In that case could you give an example of using it im my specific case?
When im trying i get the Enum error again...

I already gave the example using the Where() extension method that works exactly in your specific case without changing anything except assembly reference.

Hi again,

That is true. However this requires that the nuget Radzen.Blazor is installed. I want to avoid that and Parse the expression in the UI layer:

var newfilter = ExpressionParser.ParsePredicate<Car>(args.Filter);

However i get this error:

System.InvalidOperationException: Could not resolve type: Domain.RadzenPlayground.Models.Color
at Radzen.ExpressionParser.TryParseCastExpression(ParameterExpression parameter, Expression& expression)

There is a second parameter to this method Func<string, Type?> used for type resolving. Our entire source code as available for you free of charge - feel free to check how the expression parsing works.