Access custom functions

May 10, 2012 at 7:12 PM

I have a class with a custom function. How do I call this method in while creating the expression.

The below statement does not work? It gives an error saying that "Could not find function 'SumIf(List'1, Func'2, Func'2)' "


IGenericExpression<double> eGeneric = context.CompileGeneric<double>("SumIf(a,b,c)");


public static class Helper    


       public static double SumIf<T>(IList<T> source, Func<T, bool> pred, Func<T, double> val)


            double sum = 0;
            foreach (var item in source)

              if (pred(item)) 

                sum += val(item);
            return sum;       


May 15, 2012 at 2:57 PM

Sorry to say that this implementation will not support generics. It was done in Visual Studio 2005 and in VB at that. I like this library, but the author does not appear to be monitoring, improving or fixing this project.

I too wanted to use generics, but found that providing overloads for the types I needed was sufficient. I used generics "under the covers", but had to keep the public methods non-generic.

I have done a small amount of changes on it to enable optional parameters, and have applied some fixes provided by other users. I believe that is how most people go when they use this project.