Click here to Skip to main content
Click here to Skip to main content
Articles » Database » Database » ADO.NET » Downloads
 
Add your own
alternative version

Light ORM Library for .NET

, 8 Oct 2010
This article is about the Light Object-Relational Mapping library.
using System;
using System.Data;
using System.Collections.Generic;

namespace Light.Model
{
	/// <summary>
	/// Provides common interface for objects that contain parameters.
	/// </summary>
	public abstract class ParamContainer
	{
		/// <summary>
		/// List of parameters.
		/// </summary>
		protected List<Parameter> parameters = new List<Parameter>(3);
		
		/// <summary>
		/// Gets the list of parameters.
		/// </summary>
		public IList<Parameter> Parameters
		{
			get { return parameters; }
		}

        /// <summary>
        /// Adds a parameter.
        /// </summary>
        /// <param name="dbtype">database data type</param>
        /// <param name="value">parameter value</param>
        public void Add(DbType dbtype, object value)
        {
            Add("", dbtype, value);
        }

        /// <summary>
        /// Adds a parameter.
        /// </summary>
        /// <param name="name">parameter name</param>
        /// <param name="dbtype">database data type</param>
        /// <param name="value">parameter value</param>
        public void Add(string name, DbType dbtype, object value)
        {
            Add(name, dbtype, 0, value);
        }

        /// <summary>
        /// Adds a parameter.
        /// </summary>
        /// <param name="dbtype">database data type</param>
        /// <param name="size">size of the database data type</param>
        /// <param name="value">parameter value</param>
        public void Add(DbType dbtype, int size, object value)
        {
            Add("", dbtype, size, value);
        }

        /// <summary>
        /// Adds a parameter.
        /// </summary>
        /// <param name="name">parameter name</param>
        /// <param name="dbtype">database data type</param>
        /// <param name="size">size of the database data type</param>
        /// <param name="value">parameter value</param>
        public void Add(string name, DbType dbtype, int size, object value)
        {
            Add(name, dbtype, size, 0, 0, value);
        }
        
        /// <summary>
        /// Adds a parameter.
        /// </summary>
        /// <param name="dbtype">database data type</param>
        /// <param name="size">size of the database data type</param>
        /// <param name="precision">precision of the database data type</param>
        /// <param name="scale">scale of the database data type</param>
        /// <param name="value">parameter value</param>
        public void Add(DbType dbtype, int size, byte precision, byte scale, object value)
        {
        	Add("", dbtype, size, precision, scale, value);
        }

        /// <summary>
        /// Adds a parameter.
        /// </summary>
        /// <param name="name">parameter name</param>
        /// <param name="dbtype">database data type</param>
        /// <param name="size">size of the database data type</param>
        /// <param name="precision">precision of the database data type</param>
        /// <param name="scale">scale of the database data type</param>
        /// <param name="value">parameter value</param>
        public void Add(string name, DbType dbtype, int size, byte precision, byte scale, object value)
        {
            Parameter p = new Parameter();
            p.ParameterName = name;
            p.DBType = dbtype;
            p.Size = size;
            p.Precision = precision;
            p.Scale = scale;
            p.Value = value;
            parameters.Add(p);
        }
	}
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

Sergey Busel
Software Developer (Senior)
United States United States
No Biography provided

| Advertise | Privacy | Mobile
Web01 | 2.8.140721.1 | Last Updated 8 Oct 2010
Article Copyright 2007 by Sergey Busel
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid