Ejemplo n.º 1
0
 private static ISqlConstraint AppendWhere(ISqlConstraint old, ISqlConstraint newConstraint)
 {
     if (old != null)
     {
         newConstraint = new SqlBinaryConstraint
         {
             Left     = old,
             Opeartor = SqlBinaryConstraintType.And,
             Right    = newConstraint
         };
     }
     return(newConstraint);
 }
Ejemplo n.º 2
0
        protected override SqlBinaryConstraint VisitSqlBinaryConstraint(SqlBinaryConstraint node)
        {
            var leftBinary  = node.Left as SqlBinaryConstraint;
            var rightBinary = node.Right as SqlBinaryConstraint;
            var isLeftOr    = leftBinary != null && leftBinary.Opeartor == SqlBinaryConstraintType.Or;
            var isRightOr   = rightBinary != null && rightBinary.Opeartor == SqlBinaryConstraintType.Or;

            switch (node.Opeartor)
            {
            case SqlBinaryConstraintType.And:
                if (isLeftOr)
                {
                    _sql.Append("(");
                }
                this.Visit(node.Left);
                if (isLeftOr)
                {
                    _sql.Append(")");
                }
                _sql.AppendAnd();
                if (isRightOr)
                {
                    _sql.Append("(");
                }
                this.Visit(node.Right);
                if (isRightOr)
                {
                    _sql.Append(")");
                }
                break;

            case SqlBinaryConstraintType.Or:
                this.Visit(node.Left);
                _sql.AppendOr();
                this.Visit(node.Right);
                break;

            default:
                throw new NotSupportedException();
            }

            return(node);
        }