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
Go to top

Light ORM Library for .NET

, 8 Oct 2010
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)

Share

About the Author

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

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