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?
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:
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.
I already gave the example using the Where() extension method that works exactly in your specific case without changing anything except assembly reference.
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.