public static SqlBinaryScalarExpression Create(
     SqlBinaryScalarOperatorKind operatorKind,
     SqlScalarExpression leftExpression,
     SqlScalarExpression rightExpression)
 {
     return(new SqlBinaryScalarExpression(operatorKind, leftExpression, rightExpression));
 }
 private SqlBinaryScalarExpression(
     SqlBinaryScalarOperatorKind operatorKind,
     SqlScalarExpression left,
     SqlScalarExpression right)
 {
     this.LeftExpression  = left ?? throw new ArgumentNullException(nameof(left));
     this.OperatorKind    = operatorKind;
     this.RightExpression = right ?? throw new ArgumentNullException(nameof(right));
 }
 public SqlBinaryScalarExpression(
     SqlBinaryScalarOperatorKind operatorKind,
     SqlScalarExpression leftExpression,
     SqlScalarExpression rightExpression)
     : base(SqlObjectKind.BinaryScalarExpression)
 {
     if (leftExpression == null || rightExpression == null)
     {
         throw new ArgumentNullException();
     }
     this.OperatorKind    = operatorKind;
     this.LeftExpression  = leftExpression;
     this.RightExpression = rightExpression;
 }
        private static int SqlBinaryScalarOperatorKindGetHashCode(SqlBinaryScalarOperatorKind kind)
        {
            switch (kind)
            {
            case SqlBinaryScalarOperatorKind.Add:
                return(SqlBinaryScalarOperatorKindHashCodes.Add);

            case SqlBinaryScalarOperatorKind.And:
                return(SqlBinaryScalarOperatorKindHashCodes.And);

            case SqlBinaryScalarOperatorKind.BitwiseAnd:
                return(SqlBinaryScalarOperatorKindHashCodes.BitwiseAnd);

            case SqlBinaryScalarOperatorKind.BitwiseOr:
                return(SqlBinaryScalarOperatorKindHashCodes.BitwiseOr);

            case SqlBinaryScalarOperatorKind.BitwiseXor:
                return(SqlBinaryScalarOperatorKindHashCodes.BitwiseXor);

            case SqlBinaryScalarOperatorKind.Coalesce:
                return(SqlBinaryScalarOperatorKindHashCodes.Coalesce);

            case SqlBinaryScalarOperatorKind.Divide:
                return(SqlBinaryScalarOperatorKindHashCodes.Divide);

            case SqlBinaryScalarOperatorKind.Equal:
                return(SqlBinaryScalarOperatorKindHashCodes.Equal);

            case SqlBinaryScalarOperatorKind.GreaterThan:
                return(SqlBinaryScalarOperatorKindHashCodes.GreaterThan);

            case SqlBinaryScalarOperatorKind.GreaterThanOrEqual:
                return(SqlBinaryScalarOperatorKindHashCodes.GreaterThanOrEqual);

            case SqlBinaryScalarOperatorKind.LessThan:
                return(SqlBinaryScalarOperatorKindHashCodes.LessThan);

            case SqlBinaryScalarOperatorKind.LessThanOrEqual:
                return(SqlBinaryScalarOperatorKindHashCodes.LessThanOrEqual);

            case SqlBinaryScalarOperatorKind.Modulo:
                return(SqlBinaryScalarOperatorKindHashCodes.Modulo);

            case SqlBinaryScalarOperatorKind.Multiply:
                return(SqlBinaryScalarOperatorKindHashCodes.Multiply);

            case SqlBinaryScalarOperatorKind.NotEqual:
                return(SqlBinaryScalarOperatorKindHashCodes.NotEqual);

            case SqlBinaryScalarOperatorKind.Or:
                return(SqlBinaryScalarOperatorKindHashCodes.Or);

            case SqlBinaryScalarOperatorKind.StringConcat:
                return(SqlBinaryScalarOperatorKindHashCodes.StringConcat);

            case SqlBinaryScalarOperatorKind.Subtract:
                return(SqlBinaryScalarOperatorKindHashCodes.Subtract);

            default:
                throw new ArgumentException(string.Format(CultureInfo.CurrentUICulture, "Unsupported operator {0}", kind));
            }
        }
        private static string SqlBinaryScalarOperatorKindToString(SqlBinaryScalarOperatorKind kind)
        {
            switch (kind)
            {
            case SqlBinaryScalarOperatorKind.Add:
                return("+");

            case SqlBinaryScalarOperatorKind.And:
                return("AND");

            case SqlBinaryScalarOperatorKind.BitwiseAnd:
                return("&");

            case SqlBinaryScalarOperatorKind.BitwiseOr:
                return("|");

            case SqlBinaryScalarOperatorKind.BitwiseXor:
                return("^");

            case SqlBinaryScalarOperatorKind.Coalesce:
                return("??");

            case SqlBinaryScalarOperatorKind.Divide:
                return("/");

            case SqlBinaryScalarOperatorKind.Equal:
                return("=");

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

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

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

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

            case SqlBinaryScalarOperatorKind.Modulo:
                return("%");

            case SqlBinaryScalarOperatorKind.Multiply:
                return("*");

            case SqlBinaryScalarOperatorKind.NotEqual:
                return("!=");

            case SqlBinaryScalarOperatorKind.Or:
                return("OR");

            case SqlBinaryScalarOperatorKind.StringConcat:
                return("||");

            case SqlBinaryScalarOperatorKind.Subtract:
                return("-");

            default:
                throw new ArgumentException(string.Format(CultureInfo.CurrentUICulture, "Unsupported operator {0}", kind));
            }
        }
 public static SqlBinaryScalarExpression Create(
     SqlBinaryScalarOperatorKind operatorKind,
     SqlScalarExpression left,
     SqlScalarExpression right) => new SqlBinaryScalarExpression(operatorKind, left, right);
        public static void Append(SqlBinaryScalarOperatorKind kind, StringBuilder builder)
        {
            switch (kind)
            {
            case SqlBinaryScalarOperatorKind.Add:
                builder.Append("+");
                break;

            case SqlBinaryScalarOperatorKind.And:
                builder.Append("AND");
                break;

            case SqlBinaryScalarOperatorKind.BitwiseAnd:
                builder.Append("&");
                break;

            case SqlBinaryScalarOperatorKind.BitwiseOr:
                builder.Append("|");
                break;

            case SqlBinaryScalarOperatorKind.BitwiseXor:
                builder.Append("^");
                break;

            case SqlBinaryScalarOperatorKind.Coalesce:
                builder.Append("??");
                break;

            case SqlBinaryScalarOperatorKind.Divide:
                builder.Append("/");
                break;

            case SqlBinaryScalarOperatorKind.Equal:
                builder.Append("=");
                break;

            case SqlBinaryScalarOperatorKind.GreaterThan:
                builder.Append(">");
                break;

            case SqlBinaryScalarOperatorKind.GreaterThanOrEqual:
                builder.Append(">=");
                break;

            case SqlBinaryScalarOperatorKind.LessThan:
                builder.Append("<");
                break;

            case SqlBinaryScalarOperatorKind.LessThanOrEqual:
                builder.Append("<=");
                break;

            case SqlBinaryScalarOperatorKind.Modulo:
                builder.Append("%");
                break;

            case SqlBinaryScalarOperatorKind.Multiply:
                builder.Append("*");
                break;

            case SqlBinaryScalarOperatorKind.NotEqual:
                builder.Append("!=");
                break;

            case SqlBinaryScalarOperatorKind.Or:
                builder.Append("OR");
                break;

            case SqlBinaryScalarOperatorKind.StringConcat:
                builder.Append("||");
                break;

            case SqlBinaryScalarOperatorKind.Subtract:
                builder.Append("-");
                break;

            default:
                throw new ArgumentException(string.Format(CultureInfo.CurrentUICulture, "Unsupported operator {0}", kind));
            }
        }