예제 #1
0
        public void ConstructorWhere()
        {
            Srt2.SqlQueries.Select select = SelectCustomer();
            Or or = new Or();

            or.Add(new EqualToValue("City", "Berlin"));
            or.Add(new Equal("CustomerName", "ContactName"));
            select.Where.Add(or);
            string statement = select.ToString(DbConnectionType);

            Assert.AreEqual(Expected, statement);
        }
예제 #2
0
        public Node Expr()
        {
            var node = ExprAnd();

            while (CurrentToken == TokenCategory.OR)
            {
                var node_or = new Or()
                {
                    AnchorToken = Expect(TokenCategory.OR)
                };
                node_or.Add(node);
                node_or.Add(ExprAnd());
                node = node_or;
            }
            return(node);
        }
예제 #3
0
        /****************************************************************
         *                        Or Expression
         ***************************************************************/

        public Node OrExpression()
        {
            var expr1 = AndExpression();

            if (CurrentToken == TokenCategory.OR)
            {
                var expr2 = new Or()
                {
                    AnchorToken = Expect(TokenCategory.OR)
                };
                expr2.Add(expr1);
                expr2.Add(AndExpression());
                expr1 = expr2;
            }
            return(expr1);
        }
예제 #4
0
        public Node ExpressionOr()
        {
            var n1 = ExpressionAnd();

            while (CurrentToken == TokenCategory.OR)
            {
                var n2 = new Or()
                {
                    AnchorToken = Expect(TokenCategory.OR)
                };
                n2.Add(n1);
                n2.Add(ExpressionAnd());
                n1 = n2;
            }
            return(n1);
        }
        public Node ExprOr()
        {
            var and = ExprAnd();

            while (Current == TokenCategory.OR)
            {
                var or = new Or()
                {
                    AnchorToken = Expect(TokenCategory.OR)
                };
                or.Add(and);
                or.Add(ExprAnd());
                and = or;
            }
            return(and);
        }
예제 #6
0
        public Node Expr()
        {
            var node1 = AndExpr();

            while (Current == TokenCategory.OR)
            {
                var node2 = new Or()
                {
                    AnchorToken = Expect(TokenCategory.OR)
                };
                node2.Add(node1);
                node2.Add(AndExpr());
                node1 = node2;
            }
            return(node1);
        }
예제 #7
0
        public Node ExprOr()
        {
            Node expressionAnd = ExprAnd();

            if (CurrentToken == TokenCategory.OR)
            {
                Node expressionOr = new Or()
                {
                    AnchorToken = Expect(TokenCategory.OR)
                };
                expressionOr.Add(expressionAnd);
                expressionOr.Add(ExprAnd());
                return(expressionOr);
            }

            return(expressionAnd);
        }
예제 #8
0
        public Node ExpressionOr()
        {
            var exprAnd1 = ExpressionAnd();

            while (CurrentToken == TokenCategory.OR)
            {
                var exprAnd2 = new Or()
                {
                    AnchorToken = Expect(TokenCategory.OR)
                };
                exprAnd2.Add(exprAnd1);
                exprAnd2.Add(ExpressionAnd());
                exprAnd1 = exprAnd2;
            }

            return(exprAnd1);
        }
예제 #9
0
파일: Program.cs 프로젝트: ErikBZ/verita
        // looks like two string works!
        public static void CheckToString()
        {
            Expression x = new Expression("x");
            Expression y = new Expression("y");
            Expression z = new Expression("z");

            And a = new And();

            a.Add(x);
            a.Add(y);

            Or o = new Or();

            o.Add(a);
            o.Add(z);

            Console.WriteLine(o.ToString());
        }
예제 #10
0
        //<expr-or>//
        public Node ExpressionOr()
        {
            var andOne = ExpressionAnd();

            var Orer = andOne;

            while (CurrentToken == TokenCategory.OR)
            {
                Orer = new Or()
                {
                    AnchorToken = Expect(TokenCategory.OR)
                };
                Orer.Add(andOne);
                Orer.Add(ExpressionAnd());
                andOne = Orer;
            }
            return(Orer);
        }
예제 #11
0
        private void HandleOr(BinaryExpression b)
        {
            Expression left  = b.Left;
            Expression right = b.Right;

            #region handle alone boolean value
            MemberExpression leftMember = b.Left as MemberExpression;
            if (leftMember != null)
            {
                if (leftMember.Expression != null && leftMember.Expression.NodeType == ExpressionType.Parameter)
                {
                    if (leftMember.Type == typeof(bool)) //ex: WHERE .. && Active
                    {
                        BinaryExpression exp = BinaryExpression.MakeBinary(ExpressionType.Equal, leftMember, Expression.Constant(true));
                        left = exp;
                    }
                }
            }
            MemberExpression rightMember = b.Right as MemberExpression;
            if (rightMember != null)
            {
                if (rightMember.Expression != null && rightMember.Expression.NodeType == ExpressionType.Parameter)
                {
                    if (rightMember.Type == typeof(bool)) //ex: WHERE .. && Active
                    {
                        BinaryExpression exp = BinaryExpression.MakeBinary(ExpressionType.Equal, rightMember, Expression.Constant(true));
                        right = exp;
                    }
                }
            }
            #endregion
            if (criteria == null)
            {
                criteria = new Or();
                this.Visit(left);
                this.Visit(right);
                ((Or)criteria).Add(criteriaValues[left], criteriaValues[right]);
            }
            else
            {
                Or newCriteria = new Or();
                this.Visit(left);
                this.Visit(right);
                newCriteria.Add(criteriaValues[left], criteriaValues[right]);
                criteriaValues[b] = newCriteria;
            }
        }