Date() public static method

Creates a SqlConstant which represents a date value.
public static Date ( System.DateTime val ) : SqlConstant
val System.DateTime Value of the expression
return SqlConstant
Ejemplo n.º 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);
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Creates a SqlExpression which represents a date value.
 /// </summary>
 /// <param name="val">Value of the expression</param>
 /// <returns>A SqlExpression which represents a date value</returns>
 public static SqlExpression Date(DateTime val)
 {
     return(Constant(SqlConstant.Date(val)));
 }