private static List<FilterExpression> MergeArguments(IEnumerable<object> arguments, FilterExpression argument)
 {
     var collection = new List<FilterExpression>();
     collection.AddRange(arguments.Select(FilterExpression.FromValue));
     collection.Add(argument);
     return collection;
 }
 internal static FilterExpression FromFunction(string functionName, string targetName, IEnumerable<object> arguments)
 {
     var expression = new FilterExpression();
     expression._functionCaller = FilterExpression.FromReference(targetName);
     expression._function = new ExpressionFunction(functionName, arguments);
     return expression;
 }
 public override bool TryInvokeMember(InvokeMemberBinder binder, object[] args, out object result)
 {
     FunctionMapping mapping;
     if (FunctionMapping.SupportedFunctions.TryGetValue(new ExpressionFunction.FunctionCall(binder.Name, args.Count()), out mapping))
     {
         result = new FilterExpression() { _functionCaller = this, _function = new ExpressionFunction(binder.Name, args) };
         return true;
     }
     return base.TryInvokeMember(binder, args, out result);
 }
 public override bool TryGetMember(GetMemberBinder binder, out object result)
 {
     FunctionMapping mapping;
     if (FunctionMapping.SupportedFunctions.TryGetValue(new ExpressionFunction.FunctionCall(binder.Name, 0), out mapping))
     {
         result = new FilterExpression() {_functionCaller = this, _reference = binder.Name};
         return true;
     }
     return base.TryGetMember(binder, out result);
 }
 private static string FormatExpression(FilterExpression expr, ExpressionContext context)
 {
     if (ReferenceEquals(expr, null))
     {
         return "null";
     }
     else
     {
         return expr.Format(context);
     }
 }
 private IDictionary<string, object> TryInterpretFilterExpressionAsKey(FilterExpression expression)
 {
     bool ok = false;
     IDictionary<string, object> namedKeyValues = new Dictionary<string, object>();
     if (!ReferenceEquals(expression, null))
     {
         ok = expression.ExtractEqualityComparisons(namedKeyValues);
     }
     return ok && 
         this.Table.GetKeyNames().Count == namedKeyValues.Count() && 
         this.Table.GetKeyNames().All(namedKeyValues.ContainsKey) ? namedKeyValues : null;
 }
 public IClientWithCommand Filter(FilterExpression expression)
 {
     _namedKeyValues = TryInterpretFilterExpressionAsKey(expression);
     if (_namedKeyValues == null)
     {
         _filter = expression.Format(_client, this.Table);
     }
     else
     {
         _topCount = -1;
     }
     return _client;
 }
 private FilterExpression(FilterExpression left, FilterExpression right, ExpressionOperator expressionOperator)
 {
     _left = left;
     _right = right;
     _operator = expressionOperator;
 }
        private bool NeedsGrouping(FilterExpression expr)
        {
            if (_operator == ExpressionOperator.None)
                return false;
            if (ReferenceEquals(expr, null))
                return false;
            if (expr._operator == ExpressionOperator.None)
                return false;

            int outerPrecedence = GetPrecedence(_operator);
            int innerPrecedence = GetPrecedence(expr._operator);
            return outerPrecedence < innerPrecedence;
        }
 public IClientWithCommand Filter(FilterExpression expression)
 {
     return _command.Filter(expression);
 }
 protected FilterExpression(FilterExpression caller, ExpressionFunction function)
 {
     _functionCaller = caller;
     this.Function = function;
 }
 protected FilterExpression(FilterExpression caller, string reference)
 {
     _functionCaller = caller;
     this.Reference = reference;
 }
 protected DynamicFilterExpression(FilterExpression caller, ExpressionFunction function)
     : base(caller, function)
 {
 }
 protected DynamicFilterExpression(FilterExpression caller, string reference)
     : base(caller, reference)
 {
 }
 protected DynamicFilterExpression(FilterExpression left, FilterExpression right, ExpressionOperator expressionOperator)
     : base(left, right, expressionOperator)
 {
 }