Number() public static method

Creates a SqlConstant which represents a numeric value.
public static Number ( decimal val ) : SqlConstant
val decimal Value of the expression
return SqlConstant
Beispiel #1
0
        /// <summary>
        /// Adds a value
        /// </summary>
        /// <param name="val">The value which is to be added</param>
        /// <remarks>
        /// This method automatically determins the type of the value and creates the appropriate SqlConstant object.
        /// </remarks>
        public void Add(object val)
        {
            if (val == null)
            {
                return;
            }

            SqlConstant constant;

            if (val is string)
            {
                constant = SqlConstant.String((string)val);
            }
            else if (val is int)
            {
                constant = SqlConstant.Number((int)val);
            }
            else if (val is DateTime)
            {
                constant = SqlConstant.Date((DateTime)val);
            }
            else if (val is double)
            {
                constant = SqlConstant.Number((double)val);
            }
            else if (val is float)
            {
                constant = SqlConstant.Number((double)val);
            }
            else if (val is decimal)
            {
                constant = SqlConstant.Number((decimal)val);
            }
            else
            {
                constant = SqlConstant.String(val.ToString());
            }

            Add(constant);
        }
Beispiel #2
0
 /// <summary>
 /// Creates a SqlExpression which represents a numeric value.
 /// </summary>
 /// <param name="val">Value of the expression</param>
 /// <returns>A SqlExpression which represents a numeric value</returns>
 public static SqlExpression Number(int val)
 {
     return(Constant(SqlConstant.Number(val)));
 }