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

custom aggregate function

6 Answers 133 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Jerry
Top achievements
Rank 1
Jerry asked on 14 May 2012, 04:02 AM
Hi there,


we just update from 2011 Q1 to 2012 Q1. But there is a breaking change after update.

We got the following exception.
{System.InvalidOperationException: No generic method 'BudgetHours' on type 'Datacom.CorporateSys.SL.Project.View.Functions' is compatible with the supplied type arguments and arguments. No type arguments should be provided if the method is non-generic.

the way that I use this custom aggregate function as following
<telerik:GridViewDataColumn IsReadOnly="True" DataMemberBinding="{Binding CurrentMonthBudgetHour, Mode=OneWay}" Header="Budget Hours" >
    <telerik:GridViewDataColumn.AggregateFunctions>
        <local:BauBudgetHoursFunction Caption="Budget Hours: " />
    </telerik:GridViewDataColumn.AggregateFunctions>
</telerik:GridViewDataColumn>


originally, the code was something like this, and this is causing exception.
namespace Datacom.CorporateSys.SL.Project.View
{
    public class BudgetHoursFunction : EnumerableAggregateFunction
    {
        protected override string AggregateMethodName
        {
            get { return "BudgetHours"; }
        }
 
        protected override Type ExtensionMethodsType
        {
            get { return typeof(Functions); }
        }
    }
 
        public static decimal? BudgetHours<TSource>(IEnumerable<Task> source)
        {
            return doSomething(source);
        }
}


then I figured it out from the exception message that I should write my code like following to make it works.
namespace Datacom.CorporateSys.SL.Project.View
{
    public class BudgetHoursFunction : EnumerableAggregateFunction
    {
        protected override string AggregateMethodName
        {
            get { return "BudgetHours"; }
        }
  
        protected override Type ExtensionMethodsType
        {
            get { return typeof(Functions); }
        }
    }
  
        public static decimal? BudgetHours<TSource>(IEnumerable<object> source)
        {
            return doSomething(source);
        }
}


ok, so, my question is has Telerik update custom aggregate function between 2011 Q1 and 2012 Q1 releases? If no, then what cause this exception and why it works for 2011 Q1 release?

thank you for your time.


regards
Jerry

6 Answers, 1 is accepted

Sort by
0
Dimitrina
Telerik team
answered on 14 May 2012, 03:10 PM
Hi,

 We had some problems but they were fixed. Would it be possible for you to send us a sample project which we can debug at our end?
 

Regards,
Didie
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Jerry
Top achievements
Rank 1
answered on 14 May 2012, 09:46 PM
Hi,


You mean you have fixed the problem, so I can pass "Task" as the type, instead of generic type?

Again, is there any change to custom aggregation between 2011 Q1 to 2012 Q1 release?

thank you


regards
Jerry
0
Dimitrina
Telerik team
answered on 15 May 2012, 11:38 AM
Hi Jerry,

 We have not not done any planned change. I have attached a sample project where the custom aggregate is working fine. Would you please change it to cover your exact case so that we can debug it locally?

All the best,
Didie
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Jerry
Top achievements
Rank 1
answered on 15 May 2012, 10:00 PM
Hi there,

Thank you so much for your time and effort. Really appreciated...


If you have read my first post, I said the following scenario used to work before upgraded from 2011 Q1 to 2012 Q1
public static decimal? BudgetHours<TSource>(IEnumerable<Task> source)
{
return doSomething(source);
}


In your sample project, you used TSource, which it's a generic type I suppose
public static double StdDev<TSource>(IEnumerable<TSource> source, Func<TSource, double> selector)
{
    int itemCount = source.Count();
    if (itemCount > 1)
    {
        IEnumerable<double> values = from i in source select Convert.ToDouble(selector(i));
 
        double sum = SumAvg(values);
 
        return Math.Sqrt(sum / (itemCount - 1));
    }
 
    return 0;
}


also, my fix for the problem is the following, which I have to pass, IEnumerable<object>, where object as a generic type.
public static decimal? BudgetDollars<TSource>(IEnumerable<object> source)
{
    return SumTasksByPropertyName(source, "BudgetDollars", 0);
}

ok, so, what I am trying to ask is that, for 2011 Q1, I can pass type Task, it's working. But why do I have to pass a generic type to make it working for 2012 Q2?

thank you for your time


regards
Jerry
0
Accepted
Dimitrina
Telerik team
answered on 16 May 2012, 07:41 AM
Hi,

I have created a sample project based on your code snippets but I was not able to get the scenario working with Q1 2011. Please find the attached solution.

Do you use heterogeneous data? If so, then the reason for such a behaviour would be that we have fixed an issue about not resolving the base type of the items. Now the base type is resolved fine.


Regards,
Didie
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Jerry
Top achievements
Rank 1
answered on 16 May 2012, 10:24 PM
Hi Didie ,


That explains.

Thank you so much for your replies, really appreciated...


regards
Jerry
Tags
GridView
Asked by
Jerry
Top achievements
Rank 1
Answers by
Dimitrina
Telerik team
Jerry
Top achievements
Rank 1
Share this question
or