Ejemplo n.º 1
0
        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.Create())
            {
                sqlLiteralScalarExpression = SqlLiteralScalarExpression.SqlUndefinedLiteralScalarExpression;
            }
            else
            {
                // Either a number or string in which we need to new one up.
                sqlLiteralScalarExpression = new SqlLiteralScalarExpression(sqlLiteral);
            }

            return(sqlLiteralScalarExpression);
        }
Ejemplo n.º 2
0
        public static SqlTopSpec 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 < PremadeTopIndex) && (value >= 0))
            {
                return(SqlTopSpec.PremadeTopSpecs[value]);
            }

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

            return(new SqlTopSpec(topExpression));
        }