String() public static method

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