radzenhq / radzen-blazor

Radzen Blazor is a set of 90+ free native Blazor UI components packed with DataGrid, Scheduler, Charts and robust theming including Material design and FluentUI.
https://www.radzen.com
MIT License
3.52k stars 785 forks source link

DataGrid sorting using column headers throws exception with ASP.NET 6.0 #176

Closed dantronik-bugreporting closed 3 years ago

dantronik-bugreporting commented 3 years ago

Describe the bug Sorting the DataGrid by clicking the column headers does not work in ASP.NET 6.0

To Reproduce Steps to reproduce the behavior:

  1. Install https://dotnet.microsoft.com/download/dotnet/6.0 SDK and update the Blazor packages to the latest preview.
  2. Create an app with a Radzen DataGrid.
  3. Click the column header to sort by this column.
  4. The following stack trace is shown in the console:
    crit: Microsoft.AspNetCore.Components.WebAssembly.Rendering.WebAssemblyRenderer[100]
      Unhandled exception rendering component: TypeInitialization_Type, System.Linq.Dynamic.Core.DynamicQueryableExtensions
    System.TypeInitializationException: TypeInitialization_Type, System.Linq.Dynamic.Core.DynamicQueryableExtensions
    ---> System.Exception: Specific method not found: FirstOrDefault
    ---> System.InvalidOperationException: MoreThanOneMatch
    at System.Linq.ThrowHelper.ThrowMoreThanOneMatchException()
    at System.Linq.Enumerable.TryGetSingle[MethodInfo](IEnumerable`1 source, Func`2 predicate, Boolean& found)
    at System.Linq.Enumerable.Single[MethodInfo](IEnumerable`1 source, Func`2 predicate)
    at System.Linq.Dynamic.Core.DynamicQueryableExtensions.GetMethod(String name, Int32 parameterCount, Func`2 predicate)
    Exception_EndOfInnerExceptionStack
    at System.Linq.Dynamic.Core.DynamicQueryableExtensions.GetMethod(String name, Int32 parameterCount, Func`2 predicate)
    at System.Linq.Dynamic.Core.DynamicQueryableExtensions..cctor()
    Exception_EndOfInnerExceptionStack
    at Radzen.Blazor.RadzenGrid`1[[IKON_2_0.Shared.Models.T103_GZPROD_AN_STHF, IKON_2_0.Shared, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].get_View()
    at Radzen.PagedDataBoundComponent`1[[IKON_2_0.Shared.Models.T103_GZPROD_AN_STHF, IKON_2_0.Shared, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].get_PagedView()
    at Radzen.Blazor.RadzenGrid`1[[IKON_2_0.Shared.Models.T103_GZPROD_AN_STHF, IKON_2_0.Shared, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].BuildRenderTree(RenderTreeBuilder __builder)
    at Microsoft.AspNetCore.Components.ComponentBase.<.ctor>b__6_0(RenderTreeBuilder )
    at Microsoft.AspNetCore.Components.Rendering.ComponentState.RenderIntoBatch(RenderBatchBuilder , RenderFragment , Exception& )

Alternatively link your repo with a sample project that can be run.

Expected behavior DataGrid should be sorted.

Desktop (please complete the following information):

Additional context Issue only occurs in net6. net5 works properly.

enchev commented 3 years ago

We can't do much until this issue is addressed: https://github.com/zzzprojects/System.Linq.Dynamic.Core/issues/493