Hi,
I want to adapt a generic aggregate function to deal with null.
I tried that:
And then
But I got an exception:
Aucune méthode générique 'MyAggregateMethod' sur le type 'CustomAggregateFunctionSL.MyAggregates' n'est compatible avec les arguments de type et les arguments fournis. Aucun argument de type ne doit être fourni si la méthode n'est pas générique.
In fact, it is not only with nullable type, but with all the base type, int, double...
So why the RadGridView didn't find the MyAggregateMethod ?
It seems that it has the right prototype, I don't get it at all.
I want to adapt a generic aggregate function to deal with null.
I tried that:
public
MainPage()
{
InitializeComponent();
List<Item> items =
new
List<Item>();
for
(
int
i = 0; i < 10; i++)
{
if
(i % 2 == 0)
{
items.Add(
new
Item() { ValueDouble = 1, ValueInt =
null
});
}
else
{
items.Add(
new
Item() { ValueDouble =
null
, ValueInt = 2 });
}
}
this
.RadGridView1.ItemsSource = items;
this
.RadGridView1.Columns[0].AggregateFunctions.Add(
new
MyAggregateFunction() { SourceField =
"ValueDouble"
});
this
.RadGridView1.Columns[0].AggregateFunctions.Add(
new
MyAggregateFunction() { SourceField =
"ValueInt"
});
}
}
public
class
Item
{
public
double
? ValueDouble {
get
;
set
; }
public
int
? ValueInt {
get
;
set
; }
}
And then
public
class
MyAggregateFunction : EnumerableSelectorAggregateFunction
{
protected
override
string
AggregateMethodName
{
get
{
return
"MyAggregateMethod"
;
}
}
protected
override
Type ExtensionMethodsType
{
get
{
return
typeof
(MyAggregates);
}
}
}
public
class
MyAggregates
{
public
static
double
MyAggregateMethod<TSource, TResult>(IEnumerable<TSource> source, Func<TSource, TResult> selector)
{
// Some logic
return 0.0;
return 0.0;
}
}
But I got an exception:
Aucune méthode générique 'MyAggregateMethod' sur le type 'CustomAggregateFunctionSL.MyAggregates' n'est compatible avec les arguments de type et les arguments fournis. Aucun argument de type ne doit être fourni si la méthode n'est pas générique.
In fact, it is not only with nullable type, but with all the base type, int, double...
So why the RadGridView didn't find the MyAggregateMethod ?
It seems that it has the right prototype, I don't get it at all.