Ejemplo n.º 1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SqlBinaryExpression"/> class using the specified 
 /// <paramref name="left"/> and <paramref name="right"/> operands and the specified <paramref name="operator"/>.
 /// </summary>
 /// <param name="left">
 /// The left operand of the binary expression.
 /// </param>
 /// <param name="operator">
 /// The operator of the binary expression.
 /// </param>
 /// <param name="right">
 /// The right operand of the binary expression.
 /// </param>
 internal SqlBinaryExpression(SqlExpression left, SqlBinaryOperator @operator, SqlExpression right)
 {
     if (left == null) throw new ArgumentNullException(nameof(left));
     if (right == null) throw new ArgumentNullException(nameof(right));
     Left = left;
     Operator = @operator;
     Right = right;
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Accepts the specified <paramref name="visitor"/> and dispatches calls to the specific visitor
        /// methods for this object.
        /// </summary>
        /// <param name="operator">
        /// The <see cref="SqlBinaryOperator"/> on which to accept the visitor.
        /// </param>
        /// <param name="visitor">
        /// The <see cref="ISqlVisitor" /> to visit this object with.
        /// </param>
        public static void Accept(this SqlBinaryOperator @operator, ISqlVisitor visitor)
        {
            if (visitor == null)
            {
                throw new ArgumentNullException(nameof(visitor));
            }

            visitor.Visit(@operator);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Writes the specified operator to the output stream.
        /// </summary>
        /// <param name="operator">
        /// The operator to write to the output stream.
        /// </param>
        public void WriteOperator(SqlBinaryOperator @operator)
        {
            EnsureNotDisposed();

            switch (@operator)
            {
            case SqlBinaryOperator.And:
                WriteKeyword(SqlKeywords.And);
                break;

            case SqlBinaryOperator.Equal:
                Write("=");
                break;

            case SqlBinaryOperator.GreaterThan:
                Write(">");
                break;

            case SqlBinaryOperator.GreaterThanOrEqual:
                Write(">=");
                break;

            case SqlBinaryOperator.LessThan:
                Write("<");
                break;

            case SqlBinaryOperator.LessThanOrEqual:
                Write("<=");
                break;

            case SqlBinaryOperator.Like:
                WriteKeyword(SqlKeywords.Like);
                break;

            case SqlBinaryOperator.NotEqual:
                Write("<>");
                break;

            case SqlBinaryOperator.Or:
                WriteKeyword(SqlKeywords.Or);
                break;

            case SqlBinaryOperator.In:
                WriteKeyword(SqlKeywords.In);
                break;

            default:
#if (NET452 || NET461)
                throw new InvalidEnumArgumentException(nameof(@operator), (int)@operator, typeof(SqlBinaryOperator));
#else
                throw new ArgumentException($"The value of argument '{nameof(@operator)}' ({(int)@operator}) is invalid for Enum type '{nameof(SqlBinaryOperator)}'.");
#endif
            }
        }
Ejemplo n.º 4
0
        private static string GetOperatorText(SqlBinaryOperator op)
        {
            switch (op)
            {
            case SqlBinaryOperator.Eq:
                return("=");

            case SqlBinaryOperator.Neq:
                return("<>");

            case SqlBinaryOperator.And:
                return("and");

            case SqlBinaryOperator.Or:
                return("or");

            case SqlBinaryOperator.LessThan:
                return("<");

            case SqlBinaryOperator.LessThanOrEqual:
                return("<=");

            case SqlBinaryOperator.GreaterThan:
                return(">");

            case SqlBinaryOperator.GreaterThanOrEqual:
                return(">=");

            case SqlBinaryOperator.Plus:
                return("+");

            case SqlBinaryOperator.Minus:
                return("-");

            case SqlBinaryOperator.Mult:
                return("*");

            case SqlBinaryOperator.Div:
                return("/");

            case SqlBinaryOperator.Remainder:
                return("%");

            case SqlBinaryOperator.Like:
                return("like");

            default:
                throw new ArgumentOutOfRangeException("op", op, null);
            }
        }
Ejemplo n.º 5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SqlBinaryExpression"/> class using the specified
 /// <paramref name="left"/> and <paramref name="right"/> operands and the specified <paramref name="operator"/>.
 /// </summary>
 /// <param name="left">
 /// The left operand of the binary expression.
 /// </param>
 /// <param name="operator">
 /// The operator of the binary expression.
 /// </param>
 /// <param name="right">
 /// The right operand of the binary expression.
 /// </param>
 internal SqlBinaryExpression(SqlExpression left, SqlBinaryOperator @operator, SqlExpression right)
 {
     if (left == null)
     {
         throw new ArgumentNullException(nameof(left));
     }
     if (right == null)
     {
         throw new ArgumentNullException(nameof(right));
     }
     Left     = left;
     Operator = @operator;
     Right    = right;
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Visits the specified <see cref="SqlBinaryOperator"/>.
 /// </summary>
 /// <param name="operator">
 /// The <see cref="SqlBinaryOperator"/> to visit.
 /// </param>
 public virtual void Visit(SqlBinaryOperator @operator)
 {
 }
Ejemplo n.º 7
0
 public SqlBinaryExpression(SqlExpression left, SqlExpression right, SqlBinaryOperator @operator)
 {
     Left     = left;
     Right    = right;
     Operator = @operator;
 }
Ejemplo n.º 8
0
 public override void Visit(SqlBinaryOperator @operator)
 {
     _writer.WriteOperator(@operator);
 }
Ejemplo n.º 9
0
 public SqlBinaryExpression(SqlBinaryOperator sqlBinaryOperator, SqlExpression left, SqlExpression right)
 {
     SqlBinaryOperator = sqlBinaryOperator;
     Left  = left;
     Right = right;
 }
Ejemplo n.º 10
0
 public BinaryExpression(SqlBinaryOperator op)
 {
     Operator = op;
 }
Ejemplo n.º 11
0
 /// <summary>
 /// Visits the specified <see cref="SqlBinaryOperator"/>.
 /// </summary>
 /// <param name="operator">
 /// The <see cref="SqlBinaryOperator"/> to visit.
 /// </param>
 public virtual void Visit(SqlBinaryOperator @operator)
 {
 }