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

Error when adding a AggregateFunctions using IEnumerable <IDictionary <string,object>>

2 Answers 54 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Alexander
Top achievements
Rank 2
Alexander asked on 20 Sep 2012, 08:30 PM
When you add a AggregateFunctions this throws me the following error:

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.

I'm using IEnumerable <IDictionary <string,object>> to fill the RadGridView

2 Answers, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 21 Sep 2012, 05:25 AM
Hi,

 I'm afraid you can usually sum only numeric types - not objects. 

Regards,
Vlad
the Telerik team

Time to cast your vote for Telerik! Tell DevPro Connections and Windows IT Pro why Telerik is your choice. Telerik is nominated in a total of 25 categories.

0
Alexander
Top achievements
Rank 2
answered on 28 Sep 2012, 02:54 PM

Good Morning

I managed to solve the problem and I'll let the code, if someone else is doing the same procedure:

string campo = item["Field"].ToString();
var aggregate = new AggregateFunction<IDictionary<string,object>, string>
  {
      AggregationExpression = dic=>
          string.Format("{0:###,##0.0}",
          dic.Sum(x=> Convert.ToDouble(x[campo])))
  };
((GridViewDataColumn)gv.Columns[item[campo].ToString()]).AggregateFunctions.Add(aggregate);
Tags
GridView
Asked by
Alexander
Top achievements
Rank 2
Answers by
Vlad
Telerik team
Alexander
Top achievements
Rank 2
Share this question
or