Exemple #1
0
        public Translator(SerializationSettings serializationSettings)
        {
            _rootOperation = new WhereOperation(serializationSettings);

            _serializationSettings = serializationSettings;
            _currentOperation      = _rootOperation;
        }
Exemple #2
0
        protected override Expression VisitMethodCall(MethodCallExpression node)
        {
            Trace.WriteLine($"VisitMethodCall for {node}");

            if (node.Method.Name == "Contains")
            {
                var operation         = new CompareOperation(_serializationSettings, ComparisionMode.Contains);
                var previousOperation = _currentOperation;

                this._currentOperation.Add(operation);
                this._currentOperation = operation;

                var retVal = base.VisitMethodCall(node);

                this._currentOperation = previousOperation;

                return(retVal);
            }

            return(node);
        }
Exemple #3
0
        protected override Expression VisitBinary(BinaryExpression node)
        {
            Trace.WriteLine($"VisitBinary for {node}");

            OperationBase operationForThisNode = null;

            switch (node.NodeType)
            {
            case ExpressionType.Equal:
                operationForThisNode = new EqualityOperation(_serializationSettings);
                break;

            case ExpressionType.NotEqual:
                // _sql.Append(" <> ");
                break;

            case ExpressionType.AndAlso:
            case ExpressionType.And:
                operationForThisNode = new AndOperation(_serializationSettings);
                break;

            case ExpressionType.Or:
                // _sql.Append(" OR ");
                break;
            }

            var previousOperation = this._currentOperation;

            previousOperation.Add(operationForThisNode);

            this._currentOperation = operationForThisNode;

            Visit(node.Left);

            Visit(node.Right);

            this._currentOperation = previousOperation;

            return(node);
        }
Exemple #4
0
 public void Add(OperationBase operation)
 {
     this.Children.Add(operation);
 }