Ejemplo n.º 1
0
        /// <summary>
        /// Creates a SqlExpression which represents a constant typed value.
        /// </summary>
        /// <param name="val">SqlConstant instance</param>
        /// <returns>A SqlExpression which represents a date value</returns>
        public static SqlExpression Constant(SqlConstant val)
        {
            SqlExpression expr = new SqlExpression();

            expr.val  = val;
            expr.type = SqlExpressionType.Constant;
            return(expr);
        }
Ejemplo n.º 2
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.º 3
0
 /// <summary>
 /// Inserts an element into the SqlConstantCollection at the specified index
 /// </summary>
 /// <param name="index">
 /// The index at which the SqlConstant is to be inserted.
 /// </param>
 /// <param name="value">
 /// The SqlConstant to insert.
 /// </param>
 public virtual void Insert(int index, SqlConstant value)
 {
     List.Insert(index, value);
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Return the zero-based index of the first occurrence of a specific value
 /// in this SqlConstantCollection
 /// </summary>
 /// <param name="value">
 /// The SqlConstant value to locate in the SqlConstantCollection.
 /// </param>
 /// <returns>
 /// The zero-based index of the first occurrence of the _ELEMENT value if found;
 /// -1 otherwise.
 /// </returns>
 public virtual int IndexOf(SqlConstant value)
 {
     return(List.IndexOf(value));
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Determines whether a specfic SqlConstant value is in this SqlConstantCollection.
 /// </summary>
 /// <param name="value">
 /// The SqlConstant value to locate in this SqlConstantCollection.
 /// </param>
 /// <returns>
 /// true if value is found in this SqlConstantCollection;
 /// false otherwise.
 /// </returns>
 public virtual bool Contains(SqlConstant value)
 {
     return(List.Contains(value));
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Adds an instance of type SqlConstant to the end of this SqlConstantCollection.
 /// </summary>
 /// <param name="value">
 /// The SqlConstant to be added to the end of this SqlConstantCollection.
 /// </param>
 public virtual void Add(SqlConstant value)
 {
     List.Add(value);
 }
		/// <summary>
		/// Initializes a new instance of the SqlConstantCollection class, containing elements
		/// copied from an array.
		/// </summary>
		/// <param name="items">
		/// The array whose elements are to be added to the new SqlConstantCollection.
		/// </param>
		public SqlConstantCollection(SqlConstant[] items)
		{
			AddRange(items);
		}
		/// <summary>
		/// Removes the first occurrence of a specific SqlConstant from this SqlConstantCollection.
		/// </summary>
		/// <param name="value">
		/// The SqlConstant value to remove from this SqlConstantCollection.
		/// </param>
		public virtual void Remove(SqlConstant value)
		{
			List.Remove(value);
		}
		/// <summary>
		/// Return the zero-based index of the first occurrence of a specific value
		/// in this SqlConstantCollection
		/// </summary>
		/// <param name="value">
		/// The SqlConstant value to locate in the SqlConstantCollection.
		/// </param>
		/// <returns>
		/// The zero-based index of the first occurrence of the _ELEMENT value if found;
		/// -1 otherwise.
		/// </returns>
		public virtual int IndexOf(SqlConstant value)
		{
			return List.IndexOf(value);
		}
		/// <summary>
		/// Determines whether a specfic SqlConstant value is in this SqlConstantCollection.
		/// </summary>
		/// <param name="value">
		/// The SqlConstant value to locate in this SqlConstantCollection.
		/// </param>
		/// <returns>
		/// true if value is found in this SqlConstantCollection;
		/// false otherwise.
		/// </returns>
		public virtual bool Contains(SqlConstant value)
		{
			return List.Contains(value);
		}
		/// <summary>
		/// Adds an instance of type SqlConstant to the end of this SqlConstantCollection.
		/// </summary>
		/// <param name="value">
		/// The SqlConstant to be added to the end of this SqlConstantCollection.
		/// </param>
		public virtual void Add(SqlConstant value)
		{
			List.Add(value);
		}
		/// <summary>
		/// Adds the elements of an array to the end of this SqlConstantCollection.
		/// </summary>
		/// <param name="items">
		/// The array whose elements are to be added to the end of this SqlConstantCollection.
		/// </param>
		public virtual void AddRange(SqlConstant[] items)
		{
			foreach (SqlConstant item in items)
			{
				List.Add(item);
			}
		}
Ejemplo n.º 13
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)));
 }
Ejemplo n.º 14
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)));
 }
Ejemplo n.º 15
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)));
 }
Ejemplo n.º 16
0
 /// <summary>
 /// Removes the first occurrence of a specific SqlConstant from this SqlConstantCollection.
 /// </summary>
 /// <param name="value">
 /// The SqlConstant value to remove from this SqlConstantCollection.
 /// </param>
 public virtual void Remove(SqlConstant value)
 {
     List.Remove(value);
 }
		/// <summary>
		/// Inserts an element into the SqlConstantCollection at the specified index
		/// </summary>
		/// <param name="index">
		/// The index at which the SqlConstant is to be inserted.
		/// </param>
		/// <param name="value">
		/// The SqlConstant to insert.
		/// </param>
		public virtual void Insert(int index, SqlConstant value)
		{
			List.Insert(index, value);
		}
Ejemplo n.º 18
0
		/// <summary>
		/// Creates a SqlExpression which represents a constant typed value.
		/// </summary>
		/// <param name="val">SqlConstant instance</param>
		/// <returns>A SqlExpression which represents a date value</returns>
		public static SqlExpression Constant(SqlConstant val)
		{
			SqlExpression expr = new SqlExpression();
			expr.val = val;
			expr.type = SqlExpressionType.Constant;
			return expr;
		}