예제 #1
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));
        }
예제 #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) => new SqlNumberPathExpression(parentPath, value);
 private SqlNumberPathExpression(SqlPathExpression parentPath, SqlNumberLiteral value)
     : base(parentPath)
 {
     this.Value = value;
 }