How to use aggregate functions in CodeEffects Rule Editor?

138 Views Asked by At

Can anyone Please guide me how can I create an aggregator like SUM(), AVG() in Codeeffects RuleEditor. And these should be passed with set of integer values from the rule editor.

Like if there is an attribute like score which is of int type.........

Rule will be like:

If score equal to Zero then set score to SUM(10,20,30,40)

After this is should get this score as 100

1

There are 1 best solutions below

9
On

Define a list of integers in your source class:

public List<int> Integers {get;set;}

Define two action methods as well:

public void Sum ( List<int> list )
{
    return list.Sum( );
}
public void Add ( int i )
{
    this.Integers.Add( i );
}
public int Modulus (int operandOne, int operandTwo)
{
    return operandOne % operandTwo;
}

Now give your class as the source to the rule editor and create your rule:

If Modulus( Score, 2 ) is equal to 3
    then
        Add(10) and Add(20) and Add(30) and Add(40) and
        set Score to Sum ( Integers )