Ejemplo n.º 1
0
        public static SqlLimitSpec 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 < PremadeLimitIndex && value >= 0)
            {
                return(SqlLimitSpec.PremadeLimitSpecs[value]);
            }

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

            return(new SqlLimitSpec(limitExpression));
        }
Ejemplo n.º 2
0
        public static SqlNumberLiteral Create(Number64 number64)
        {
            SqlNumberLiteral sqlNumberLiteral;

            if (number64.IsDouble)
            {
                if (!SqlNumberLiteral.FrequentDoubles.TryGetValue(Number64.ToDouble(number64), out sqlNumberLiteral))
                {
                    sqlNumberLiteral = new SqlNumberLiteral(number64);
                }
            }
            else
            {
                if (!SqlNumberLiteral.FrequentLongs.TryGetValue(Number64.ToLong(number64), out sqlNumberLiteral))
                {
                    sqlNumberLiteral = new SqlNumberLiteral(number64);
                }
            }

            return(sqlNumberLiteral);
        }
 public static SqlNumberPathExpression Create(SqlPathExpression parentPath, SqlNumberLiteral value)
 {
     return(new SqlNumberPathExpression(parentPath, value));
 }
 private SqlNumberPathExpression(SqlPathExpression parentPath, SqlNumberLiteral value)
     : base(SqlObjectKind.NumberPathExpression, parentPath)
 {
     this.Value = value;
 }