This is a migrated thread and some comments may be shown as answers.

Custom aggregate signature

1 Answer 69 Views
GridView
This is a migrated thread and some comments may be shown as answers.
David
Top achievements
Rank 1
David asked on 13 Aug 2010, 01:33 PM
I am trying to implement a custom aggregate function so I can use values from multiple columns.

The GridView is bound to a collection of row ViewModels which expose a set of properties of type double.

I have created a custom aggregate function:
public class CustomAggregateFunction : EnumerableSelectorAggregateFunction
    {
        protected override string AggregateMethodName
        {
            get { return "CustomAggregate"; }
        }

        protected override Type ExtensionMethodsType
        {
            get { return typeof (CustomAggregateCalculator); }
        }
    }

I am struggling with the signature of the aggregation method, the following:
public static class CustomAggregateCalculator 
    {
        public static double CustomAggregate<TSource>(this IEnumerable<TSource> source, Func<TSource, double> selector)
        {
            return 0;
        }
    }

Gives me the following exception:
System.InvalidOperationException occurred
  Message=No method 'CustomAggregate' on type 'IntelHedgerGUI.ViewModel.CustomAggregateCalculator' is compatible with the supplied arguments.
  Source=System.Core
  StackTrace:
       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.Windows.Data.Expressions.EnumerableSelectorAggregateFunctionExpressionBuilder.CreateMethodCallExpression(LambdaExpression memberSelectorExpression) in c:\Builds\WPF_Scrum\Release_WPF_2010_Q2\Sources\Development\Core\Data\Expressions\Grouping\Aggregates\EnumerableSelectorAggregateFunctionExpressionBuilder.cs:line 48

What signature should the CustomAggregate method have?

1 Answer, 1 is accepted

Sort by
0
Maya
Telerik team
answered on 13 Aug 2010, 02:13 PM
Hi David,

In order to provide you with an appropriate solution, we would need more details. Mainly, about the source for that Aggregate Function, its SourceField and the basic settings of the project. It would be great if you could send us a sample project or at least paste some of your code here.
 

All the best,
Maya
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
GridView
Asked by
David
Top achievements
Rank 1
Answers by
Maya
Telerik team
Share this question
or