public static SqlLiteralScalarExpression Create(SqlLiteral sqlLiteral)
        {
            SqlLiteralScalarExpression sqlLiteralScalarExpression;

            if (sqlLiteral == SqlBooleanLiteral.True)
            {
                sqlLiteralScalarExpression = SqlLiteralScalarExpression.SqlTrueLiteralScalarExpression;
            }
            else if (sqlLiteral == SqlBooleanLiteral.False)
            {
                sqlLiteralScalarExpression = SqlLiteralScalarExpression.SqlFalseLiteralScalarExpression;
            }
            else if (sqlLiteral == SqlNullLiteral.Singleton)
            {
                sqlLiteralScalarExpression = SqlLiteralScalarExpression.SqlNullLiteralScalarExpression;
            }
            else if (sqlLiteral == SqlUndefinedLiteral.Singleton)
            {
                sqlLiteralScalarExpression = SqlLiteralScalarExpression.SqlUndefinedLiteralScalarExpression;
            }
            else
            {
                // Either a number or string in which we need to new one up.
                sqlLiteralScalarExpression = new SqlLiteralScalarExpression(sqlLiteral);
            }

            return(sqlLiteralScalarExpression);
        }
Exemple #2
0
        public override int Visit(SqlLiteralScalarExpression sqlLiteralScalarExpression)
        {
            int hashCode = SqlLiteralScalarExpressionHashCode;

            hashCode = CombineHashes(hashCode, sqlLiteralScalarExpression.Literal.Accept(this));
            return(hashCode);
        }
        public static SqlOffsetSpec Create(SqlNumberLiteral sqlNumberLiteral)
        {
            if (sqlNumberLiteral == null)
            {
                throw new ArgumentNullException(nameof(sqlNumberLiteral));
            }

            long value;

            if (!sqlNumberLiteral.Value.IsInteger)
            {
                throw new ArgumentOutOfRangeException($"Expected {nameof(sqlNumberLiteral)} to be an integer.");
            }

            value = Number64.ToLong(sqlNumberLiteral.Value);
            if (value < PremadeOffsetIndex && value >= 0)
            {
                return(SqlOffsetSpec.PremadeOffsetSpecs[value]);
            }

            SqlScalarExpression offsetExpression = SqlLiteralScalarExpression.Create(
                SqlNumberLiteral.Create(
                    value));

            return(new SqlOffsetSpec(offsetExpression));
        }
 public override SqlObject Visit(SqlLiteralScalarExpression sqlLiteralScalarExpression)
 {
     return(SqlLiteralScalarExpression.Create(sqlLiteralScalarExpression.Literal.Accept(this) as SqlLiteral));
 }
 public abstract void Visit(SqlLiteralScalarExpression scalarExpression);
 public override void Visit(SqlLiteralScalarExpression sqlLiteralScalarExpression)
 {
     sqlLiteralScalarExpression.Literal.Accept(this);
 }
 protected abstract SqlScalarExpression Visit(SqlLiteralScalarExpression expression);