/// <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; }
/// <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); }
/// <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 } }
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); } }
/// <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; }
/// <summary> /// Visits the specified <see cref="SqlBinaryOperator"/>. /// </summary> /// <param name="operator"> /// The <see cref="SqlBinaryOperator"/> to visit. /// </param> public virtual void Visit(SqlBinaryOperator @operator) { }
public SqlBinaryExpression(SqlExpression left, SqlExpression right, SqlBinaryOperator @operator) { Left = left; Right = right; Operator = @operator; }
public override void Visit(SqlBinaryOperator @operator) { _writer.WriteOperator(@operator); }
public SqlBinaryExpression(SqlBinaryOperator sqlBinaryOperator, SqlExpression left, SqlExpression right) { SqlBinaryOperator = sqlBinaryOperator; Left = left; Right = right; }
public BinaryExpression(SqlBinaryOperator op) { Operator = op; }