Completed
Last Updated: 11 Mar 2024 09:39 by ADMIN
Release 2.30.0
Marco
Created on: 06 Nov 2020 15:39
Category: Grid
Type: Bug Report
19
Grid with ExpandoObject or grouping with OnRead throws when adding Sum Aggregate

In a Grid loaded with data made of ExpandoObject, set an aggregate GridAggregateType.Sum breaks the grouping feature while GridAggregateType Max, Min and Count work properly

Please find the attached project: in the grid on Index.razor grouping does not work, just comment Index.razor:43 to restore grouping feature


Exception message:

Error: System.InvalidOperationException: No generic method 'Sum' on type 'System.Linq.Enumerable' is compatible with the supplied type arguments and arguments. No type arguments should be provided if the method is non-generic. 
   at System.Linq.Expressions.Expression.FindMethod(Type type, String methodName, Type[] typeArgs, Expression[] args, BindingFlags flags)
   at System.Linq.Expressions.Expression.Call(Type type, String methodName, Type[] typeArguments, Expression[] arguments)
   at Telerik.DataSource.Expressions.EnumerableSelectorAggregateFunctionExpressionBuilder.CreateMethodCallExpression(LambdaExpression memberSelectorExpression)
   at Telerik.DataSource.Expressions.EnumerableSelectorAggregateFunctionExpressionBuilder.CreateAggregateExpression()
   at Telerik.DataSource.EnumerableSelectorAggregateFunction.CreateAggregateExpression(Expression enumerableExpression, Boolean liftMemberAccessToNull)
   at Telerik.DataSource.Expressions.GroupDescriptorExpressionBuilder.<ProjectionPropertyValueExpressions>b__39_0(AggregateFunction f)
   at System.Linq.Enumerable.SelectIListIterator`2.ToList()
   at Telerik.DataSource.Expressions.GroupDescriptorExpressionBuilder.CreateProjectionInitExpression()
   at Telerik.DataSource.Expressions.GroupDescriptorExpressionBuilder.CreateAggregateFunctionsProjectionMemberBinding()
   at Telerik.DataSource.Expressions.QueryableAggregatesExpressionBuilder.CreateMemberBindings()+MoveNext()
   at System.Collections.Generic.LargeArrayBuilder`1.AddRange(IEnumerable`1 items)
   at System.Collections.Generic.EnumerableHelpers.ToArray[T](IEnumerable`1 source)
   at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
   at System.Dynamic.Utils.CollectionExtensions.ToReadOnly[T](IEnumerable`1 enumerable)
   at System.Linq.Expressions.Expression.MemberInit(NewExpression newExpression, IEnumerable`1 bindings)
   at Telerik.DataSource.Expressions.GroupDescriptorExpressionBuilder.CreateSelectBodyExpression()
   at Telerik.DataSource.Expressions.GroupDescriptorExpressionBuilder.CreateSelectExpression()
   at Telerik.DataSource.Expressions.GroupDescriptorExpressionBuilderBase.CreateQuery()
   at Telerik.DataSource.Extensions.QueryableExtensions.Aggregate(IQueryable source, IEnumerable`1 aggregateFunctions)
   at Telerik.DataSource.Extensions.QueryableExtensions.CreateDataSourceResult[TModel,TResult](IQueryable queryable, DataSourceRequest request, Func`2 selector)
   at Telerik.DataSource.Extensions.QueryableExtensions.ToDataSourceResult(IQueryable queryable, DataSourceRequest request)
   at Telerik.DataSource.Extensions.QueryableExtensions.ToDataSourceResult(IEnumerable enumerable, DataSourceRequest request)
   at Telerik.Blazor.Data.TelerikDataSourceBase.ProcessData(IEnumerable data)
   at Telerik.Blazor.Components.Common.DataBoundComponent`1.ProcessDataInternal()
   at Telerik.Blazor.Components.Common.DataBoundComponent`1.ProcessDataAsync()
   at Telerik.Blazor.Components.TelerikGrid`1.DataBoundProcessData()
   at Telerik.Blazor.Components.TelerikGrid`1.ProcessDataAsync()
   at Telerik.Blazor.Components.TelerikGrid`1.ApplyFiltersAsync()
   at Telerik.Blazor.Components.TelerikGrid`1.OnFilterChange(FilterDescriptorBase filter)
   at Telerik.Blazor.Components.Common.Filters.TelerikFilterHeader`1.Filter(FilterDescriptor filterDescriptor)
   at Telerik.Blazor.Components.Common.Filters.TelerikFilterHeader`1.OnValueChanged(Object newValue)
   at System.Threading.Tasks.Task.<>c.<ThrowAsync>b__139_0(Object state)
   at Microsoft.AspNetCore.Components.Rendering.RendererSynchronizationContext.ExecuteSynchronously(TaskCompletionSource`1 completion, SendOrPostCallback d, Object state)
   at Microsoft.AspNetCore.Components.Rendering.RendererSynchronizationContext.<>c.<.cctor>b__23_0(Object state)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location where exception was thrown ---
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at Microsoft.AspNetCore.Components.Rendering.RendererSynchronizationContext.ExecuteBackground(WorkItem item)

 

Attached Files:
7 comments
ADMIN
Hristian Stefanov
Posted on: 11 Mar 2024 09:39

Hi David,

Thank you for sharing the outcome of your situation.

I'm happy to see you have quickly resolved the matter on your own.

Regards,
Hristian Stefanov
Progress Telerik

Stay tuned by visiting our public roadmap and feedback portal pages! Or perhaps, if you are new to our Telerik family, check out our getting started resources!
David
Posted on: 07 Mar 2024 14:02
Update!  I found that adding the FieldType="@typeof(int)" fixed it for me.  So just adding that FieldType to the GridAggregate tag seems to work.
David
Posted on: 07 Mar 2024 13:51
What is the status of this?  I am running into the same issue.  This issue was identified over 3 years ago.  Seems like there should be a fix or work around by now.
ADMIN
Hristian Stefanov
Posted on: 28 Jul 2023 08:06

Hi Joe,

In order to better understand and address the issue, I have made attempts to replicate it by extensively testing various Grid configurations with OnRead. However, I could not reproduce the error on my end.

To effectively investigate and assist you, can you please provide a small, runnable sample that reproduces the issue? You can utilize the REPL platform for your convenience instead of attaching a complete project. This will allow me to conduct a more comprehensive analysis within an environment that closely resembles your specific setup.

On a side note, please ensure to set AggregateResults in the GridReadEventArgs event argument object when using OnRead in conjunction with aggregates. This is a requirement for the Grid so the aggregates can function properly. For more details, refer to the Notes section (last bullet point).

Your cooperation is highly valuable, and I look forward to hearing from you.

Regards,
Hristian Stefanov
Progress Telerik

Stay tuned by visiting our public roadmap and feedback portal pages! Or perhaps, if you are new to our Telerik family, check out our getting started resources!
Joe
Posted on: 21 Jul 2023 11:17
I am getting a similar problem.  I use the OnRead construct to overcome a problem with TelerikGrid and Edit but using this breaks any aggregate sums.
ADMIN
Marin Bratanov
Posted on: 20 Apr 2021 16:00

Hello Paul,

There isn't a predefined number of votes, when items go from the backlog to the roadmap and into development is a very complex process that takes many factors into account.

The best way to know when something is implemented is to click the Follow button on its page so you get emails for status updates.

At the moment, I'm afraid I cannot offer a workaround. If you can move towards using actual models rather than dynamic expandos, aggregates will work without this exception.

Regards,
Marin Bratanov
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Paul
Posted on: 20 Apr 2021 15:18

Hi- roughly how many votes would this need to become a scheduled fix? Also is there a recommended local work around?

Thank you