Dynamic Select() broken on 6.1.4 #1649

Open
opened 2026-01-29 17:56:44 +00:00 by claunia · 0 comments
Owner

Originally created by @XorZy on GitHub (Mar 2, 2025).

Describe the bug
I am trying to switch to Radzen 6.x.
I am aware that the dependency on DynamicLinq has been dropped but the replacement methods do not seem to cover all use cases, even very basic ones.
I use reflection to query specific rows of an entity type.
The following code used to work on Radzen 5

...
return await dbSet.Select($"x=>x.{property.Name}").ToDynamicArrayAsync();

But now it throws this exception :

System.InvalidOperationException: Invalid selector: x=>x_Brand = it.x=>x?.Brand.
 ---> System.NotSupportedException: Unsupported initializer: x=>x_Brand = it.x
   at Radzen.ExpressionSyntaxVisitor.GetPropertyNameFromInitializer(AnonymousObjectMemberDeclaratorSyntax initializer)
   at Radzen.ExpressionSyntaxVisitor.<>c__DisplayClass23_0.<VisitAnonymousObjectCreationExpression>b__0(AnonymousObjectMemberDeclaratorSyntax init)
   at System.Linq.Enumerable.IEnumerableSelectIterator`2.ToList()
   at Radzen.ExpressionSyntaxVisitor.VisitAnonymousObjectCreationExpression(AnonymousObjectCreationExpressionSyntax node)
   at Microsoft.CodeAnalysis.CSharp.Syntax.AnonymousObjectCreationExpressionSyntax.Accept[TResult](CSharpSyntaxVisitor`1 visitor)
   at Microsoft.CodeAnalysis.CSharp.CSharpSyntaxVisitor`1.Visit(SyntaxNode node)
   at Radzen.ExpressionParser.Parse[T](String expression, Func`2 typeLocator)
   at Radzen.ExpressionParser.ParseLambda[T](String expression, Func`2 typeLocator)
   at System.Linq.Dynamic.Core.DynamicExtensions.<>c__3`1.<Select>b__3_0(String expression)
   at System.Linq.Dynamic.Core.DynamicExtensions.Select(IQueryable source, String selector, Func`2 lambdaCreator)
   --- End of inner exception stack trace ---
   at System.Linq.Dynamic.Core.DynamicExtensions.Select(IQueryable source, String selector, Func`2 lambdaCreator)
   at System.Linq.Dynamic.Core.DynamicExtensions.Select[T](IQueryable`1 source, String selector, Object[] parameters)

I am not sure why Radzen changes my expression from x=>x.Property to x=>x_Property = it.x=>x?.Property, which seems to be at the source of the issue.

I have added an explicit reference to my csproj, but for some reason the Radzen Extensions Methods are still being used instead.
<PackageReference Include="System.Linq.Dynamic.Core" Version="*" />

Is this use case supported?
And if not how to actually make sure the Radzen Extensions Method are not used?

Originally created by @XorZy on GitHub (Mar 2, 2025). **Describe the bug** I am trying to switch to Radzen 6.x. I am aware that the dependency on DynamicLinq has been dropped but the replacement methods do not seem to cover all use cases, even very basic ones. I use reflection to query specific rows of an entity type. The following code used to work on Radzen 5 ```csharp ... return await dbSet.Select($"x=>x.{property.Name}").ToDynamicArrayAsync(); ``` But now it throws this exception : ```csharp System.InvalidOperationException: Invalid selector: x=>x_Brand = it.x=>x?.Brand. ---> System.NotSupportedException: Unsupported initializer: x=>x_Brand = it.x at Radzen.ExpressionSyntaxVisitor.GetPropertyNameFromInitializer(AnonymousObjectMemberDeclaratorSyntax initializer) at Radzen.ExpressionSyntaxVisitor.<>c__DisplayClass23_0.<VisitAnonymousObjectCreationExpression>b__0(AnonymousObjectMemberDeclaratorSyntax init) at System.Linq.Enumerable.IEnumerableSelectIterator`2.ToList() at Radzen.ExpressionSyntaxVisitor.VisitAnonymousObjectCreationExpression(AnonymousObjectCreationExpressionSyntax node) at Microsoft.CodeAnalysis.CSharp.Syntax.AnonymousObjectCreationExpressionSyntax.Accept[TResult](CSharpSyntaxVisitor`1 visitor) at Microsoft.CodeAnalysis.CSharp.CSharpSyntaxVisitor`1.Visit(SyntaxNode node) at Radzen.ExpressionParser.Parse[T](String expression, Func`2 typeLocator) at Radzen.ExpressionParser.ParseLambda[T](String expression, Func`2 typeLocator) at System.Linq.Dynamic.Core.DynamicExtensions.<>c__3`1.<Select>b__3_0(String expression) at System.Linq.Dynamic.Core.DynamicExtensions.Select(IQueryable source, String selector, Func`2 lambdaCreator) --- End of inner exception stack trace --- at System.Linq.Dynamic.Core.DynamicExtensions.Select(IQueryable source, String selector, Func`2 lambdaCreator) at System.Linq.Dynamic.Core.DynamicExtensions.Select[T](IQueryable`1 source, String selector, Object[] parameters) ``` I am not sure why Radzen changes my expression from **x=>x.Property** to **x=>x_Property = it.x=>x?.Property**, which seems to be at the source of the issue. I have added an explicit reference to my csproj, but for some reason the Radzen Extensions Methods are still being used instead. ` <PackageReference Include="System.Linq.Dynamic.Core" Version="*" />` Is this use case supported? And if not how to actually make sure the Radzen Extensions Method are not used?
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/radzen-blazor#1649