private static MethodCallExpression AggCallExpression(AggregationMethod aggMethod, ParameterExpression sourceParameter, LambdaExpression lambda)
        {
            String methodName;

            switch (aggMethod)
            {
            case AggregationMethod.Average:
                methodName = nameof(Enumerable.Average);
                break;

            case AggregationMethod.CountDistinct:
                return(CountDistinctExpression(sourceParameter, lambda));

            case AggregationMethod.Max:
                methodName = nameof(Enumerable.Max);
                break;

            case AggregationMethod.Min:
                methodName = nameof(Enumerable.Min);
                break;

            case AggregationMethod.Sum:
                methodName = nameof(Enumerable.Sum);
                break;

            default:
                throw new NotSupportedException();
            }

            MethodInfo closeMethod;
            MethodInfo openMethod = OeMethodInfoHelper.GetAggMethodInfo(methodName, lambda.ReturnType);

            if (openMethod == null)
            {
                Func <IEnumerable <Object>, Func <Object, Object>, Object> aggFunc;
                switch (aggMethod)
                {
                case AggregationMethod.Max:
                    aggFunc = Enumerable.Max <Object, Object>;
                    break;

                case AggregationMethod.Min:
                    aggFunc = Enumerable.Min <Object, Object>;
                    break;

                default:
                    throw new InvalidOperationException($"Enumerable.{methodName} not found");;
                }
                openMethod  = aggFunc.GetMethodInfo().GetGenericMethodDefinition();
                closeMethod = openMethod.MakeGenericMethod(lambda.Parameters[0].Type, lambda.ReturnType);
            }
            else
            {
                closeMethod = openMethod.MakeGenericMethod(lambda.Parameters[0].Type);
            }

            return(Expression.Call(closeMethod, sourceParameter, lambda));
        }