Esempio n. 1
0
        private static ODataExpression ParseCallExpression(Expression expression)
        {
            var callExpression = expression as MethodCallExpression;

            if (callExpression.Object == null)
            {
                var target = callExpression.Arguments.FirstOrDefault();
                if (target != null)
                {
                    return(FromFunction(callExpression.Method.Name, ParseLinqExpression(target).Reference,
                                        callExpression.Arguments.Skip(1)));
                }
                else
                {
                    throw Utils.NotSupportedExpression(expression);
                }
            }
            else
            {
                switch (callExpression.Object.NodeType)
                {
                case ExpressionType.MemberAccess:
                    var memberExpression = callExpression.Object as MemberExpression;
                    var arguments        = new List <object>();
                    arguments.AddRange(callExpression.Arguments.Select(ParseCallArgumentExpression));
                    var function = new ExpressionFunction(callExpression.Method.Name, arguments);
                    return(new ODataExpression(ParseMemberExpression(memberExpression), function));

                case ExpressionType.Call:
                    return(ParseCallExpression(callExpression.Object));
                }

                throw Utils.NotSupportedExpression(callExpression.Object);
            }
        }
        protected internal ODataExpression(ODataExpression expression)
        {
            _functionCaller = expression._functionCaller;
            _left = expression._left;
            _right = expression._right;
            _operator = expression._operator;
            _conversionType = expression._conversionType;

            this.Reference = expression.Reference;
            this.Value = expression.Value;
            this.Function = expression.Function;
        }
        protected internal ODataExpression(ODataExpression expression)
        {
            _functionCaller = expression._functionCaller;
            _left           = expression._left;
            _right          = expression._right;
            _operator       = expression._operator;
            _conversionType = expression._conversionType;

            this.Reference = expression.Reference;
            this.Value     = expression.Value;
            this.Function  = expression.Function;
        }
 protected DynamicODataExpression(ODataExpression caller, ExpressionFunction function)
     : base(caller, function)
 {
 }
 protected DynamicODataExpression(ExpressionFunction function)
     : base(function)
 {
 }
 protected internal ODataExpression(ODataExpression caller, ExpressionFunction function)
 {
     _functionCaller = caller;
     this.Function   = function;
 }
 protected DynamicFilterExpression(FilterExpression caller, ExpressionFunction function)
     : base(caller, function)
 {
 }
 protected internal ODataExpression(ExpressionFunction function)
 {
     this.Function = function;
 }
        private static ODataExpression ParseCallExpression(Expression expression)
        {
            var callExpression = expression as MethodCallExpression;
            if (callExpression.Object == null)
            {
                var target = callExpression.Arguments.FirstOrDefault();
                if (target != null)
                {
                    var callArguments = string.Equals(callExpression.Method.DeclaringType.FullName, "System.Convert", StringComparison.Ordinal)
                        ? callExpression.Arguments
                        : callExpression.Arguments.Skip(1);
                    return FromFunction(callExpression.Method.Name, ParseLinqExpression(target).Reference, callArguments);
                }
                else
                {
                    throw Utils.NotSupportedExpression(expression);
                }
            }
            else
            {
                switch (callExpression.Object.NodeType)
                {
                    case ExpressionType.MemberAccess:
                        var memberExpression = callExpression.Object as MemberExpression;
                        var arguments = new List<object>();
                        arguments.AddRange(callExpression.Arguments.Select(ParseCallArgumentExpression));
                        var function = new ExpressionFunction(callExpression.Method.Name, arguments);
                        return new ODataExpression(ParseMemberExpression(memberExpression), function);

                    case ExpressionType.Call:
                        return ParseCallExpression(callExpression.Object);
                }

                throw Utils.NotSupportedExpression(callExpression.Object);
            }
        }
 protected DynamicODataExpression(ODataExpression caller, ExpressionFunction function)
     : base(caller, function)
 {
 }
 internal static FilterExpression FromFunction(ExpressionFunction function)
 {
     return new FilterExpression { _function = function };
 }
 protected FilterExpression(FilterExpression caller, ExpressionFunction function)
 {
     _functionCaller = caller;
     this.Function = function;
 }
 protected FilterExpression(ExpressionFunction function)
 {
     this.Function = function;
 }
Esempio n. 14
0
 public static bool TryGetOperatorMapping(ODataExpression functionCaller, ExpressionFunction function, AdapterVersion adapterVersion,
                                          out FunctionToOperatorMapping operatorMapping)
 {
     operatorMapping = DefinedMappings.SingleOrDefault(x => x.CanMap(function.FunctionName, function.Arguments.Count, functionCaller, adapterVersion));
     return(operatorMapping != null);
 }
Esempio n. 15
0
 protected ODataExpression(ExpressionFunction function)
 {
     this.Function = function;
 }
 protected DynamicODataExpression(ExpressionFunction function)
     : base(function)
 {
 }
 public FunctionDefinition(ExpressionFunction.FunctionCall functionCall, FunctionMapping functionMapping, AdapterVersion adapterVersion = AdapterVersion.Any)
 {
     FunctionCall = functionCall;
     FunctionMapping = functionMapping;
     AdapterVersion = adapterVersion;
 }
 protected ODataExpression(ExpressionFunction function)
 {
     this.Function = function;
 }
 internal static ODataExpression FromFunction(ExpressionFunction function)
 {
     return(new ODataExpression(function));
 }
 internal static ODataExpression FromFunction(ExpressionFunction function)
 {
     return new ODataExpression(function);
 }
 protected internal ODataExpression(ExpressionFunction function)
 {
     this.Function = function;
 }
 protected internal ODataExpression(ODataExpression caller, ExpressionFunction function)
 {
     _functionCaller = caller;
     this.Function = function;
 }
 protected DynamicFilterExpression(ExpressionFunction function)
     : base(function)
 {
 }