Click here to Skip to main content
15,886,199 members
Articles / Database Development / SQL Server

Light ORM Library for .NET

Rate me:
Please Sign up or sign in to vote.
4.83/5 (39 votes)
8 Oct 2010CPOL17 min read 221.1K   3.1K   184  
This article is about the Light Object-Relational Mapping library.
using System;
using System.Collections.Generic;

namespace Light
{
	/// <summary>
	/// Represents a callable procedure.
	/// </summary>
	public class Procedure : Light.Model.ParamContainer, IEquatable<Procedure>
	{
		private string name;
		
		/// <summary>
		/// Creates a new instance.
		/// </summary>
		/// <param name="name">procedure name</param>
		/// <param name="parameterList">list of parameters</param>
		public Procedure(string name, IEnumerable<Parameter> parameterList)
		{
			this.name = name;
			if(parameterList != null)
				parameters.AddRange(parameterList);
		}
		
		/// <summary>
		/// Creates a new instance.
		/// </summary>
		/// <param name="name">procedure name</param>
		public Procedure(string name) : this(name, null)
		{}
		
		/// <summary>
		/// Creates a new instance.
		/// </summary>
		public Procedure() : this("")
		{}
		
		/// <summary>
		/// Gets or sets the name.
		/// </summary>
		public string Name
		{
			get { return name; }
			set { name = value; }
		}
		
		/// <summary>
		/// Sets the name and returns a reference to this object.
		/// </summary>
		/// <param name="name">name to set</param>
		/// <returns>reference to this object</returns>
		public Procedure SetName(string name)
		{
			this.name = name;
			return this;
		}
		
		/// <summary>
		/// Adds the given parameter and returns a reference to this object.
		/// </summary>
		/// <param name="parameter">parameter to add</param>
		/// <returns>reference to this object</returns>
		public Procedure Add(Parameter parameter)
		{
			if(parameter != null)
				parameters.Add(parameter);
			return this;
		}
		
		/// <summary>
		/// Adds given parameters and returns a reference to this object.
		/// </summary>
		/// <param name="parameters">parameters to add</param>
		/// <returns>reference to this object</returns>
		public Procedure Add(params Parameter[] parameters)
		{
			this.parameters.AddRange(parameters);
			return this;
		}
		
		/// <summary>
		/// Compares for equality. Two procedures are equals if their name
		/// and number of parameters are the same.
		/// </summary>
		/// <param name="other">procedure to compare</param>
		/// <returns>true if equal, false otherwise</returns>
		public override bool Equals(object other)
		{
			if(other is Procedure)
				return Equals((Procedure) other);
			return false;
		}
		
		/// <summary>
		/// Compares for equality. Two procedures are equals if their name
		/// and number of parameters are the same.
		/// </summary>
		/// <param name="other">procedure to compare</param>
		/// <returns>true if equal, false otherwise</returns>
		public bool Equals(Procedure other)
		{
			if(other == null)
				return false;
			return this.name == null ? other.name == null : this.name.Equals(other.name);
		}
		
		/// <summary>
		/// Gets the hash code.
		/// </summary>
		/// <returns>hash code</returns>
		public override int GetHashCode()
		{
			return base.GetHashCode();
		}
	}
}

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)


Written By
Software Developer (Senior)
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions