Click here to Skip to main content
15,894,646 members
Articles / Database Development / SQL Server

Optimizing Performance in NHibernate: Part 2: A Collection of Enhancements

Rate me:
Please Sign up or sign in to vote.
4.86/5 (24 votes)
9 May 2007CPOL19 min read 199.5K   810   110  
This is the second part in a two-piece article focused on optimizing the efficiency of your NHibernate ORM layer.
using System;
using System.Collections;

namespace Northwind.Domain.Entities
{
	/// <summary>
	/// Customer object for NHibernate mapped table 'Customers'.
	/// </summary>
    public class Customer : EntityBase
	{
		#region Member Variables
		
		protected string _id;
		protected string _companyName;
		protected string _contactName;
		protected string _contactTitle;
		protected string _address;
		protected string _city;
		protected string _region;
		protected string _postalCode;
		protected string _country;
		protected string _phone;
		protected string _fax;
		protected IList _orderses;
		protected IList _customerCustomerTypes;

		#endregion

		#region Constructors

		public Customer() { }

		public Customer( string companyName, string contactName, string contactTitle, string address, string city, string region, string postalCode, string country, string phone, string fax )
		{
			this._companyName = companyName;
			this._contactName = contactName;
			this._contactTitle = contactTitle;
			this._address = address;
			this._city = city;
			this._region = region;
			this._postalCode = postalCode;
			this._country = country;
			this._phone = phone;
			this._fax = fax;
		}

		#endregion

		#region Public Properties

		public string Id
		{
			get {return _id;}
			set
			{
				if(value != _id) IsModified = true;
				_id = value;
			}
		}

		public string CompanyName
		{
			get { return _companyName; }
			set
			{
				if(value != _companyName) IsModified = true;
				_companyName = value;
			}
		}

		public string ContactName
		{
			get { return _contactName; }
			set
			{
				if(value != _contactName) IsModified = true;
				_contactName = value;
			}
		}

		public string ContactTitle
		{
			get { return _contactTitle; }
			set
			{
				if(value != _contactTitle) IsModified = true;
				_contactTitle = value;
			}
		}

		public string Address
		{
			get { return _address; }
			set
			{
				if(value != _address) IsModified = true;
				_address = value;
			}
		}

		public string City
		{
			get { return _city; }
			set
			{
				if(value != _city) IsModified = true;
				_city = value;
			}
		}

		public string Region
		{
			get { return _region; }
			set
			{
				if(value != _region) IsModified = true;
				_region = value;
			}
		}

		public string PostalCode
		{
			get { return _postalCode; }
			set
			{
				if(value != _postalCode) IsModified = true;
				_postalCode = value;
			}
		}

		public string Country
		{
			get { return _country; }
			set
			{
				if(value != _country) IsModified = true;
				_country = value;
			}
		}

		public string Phone
		{
			get { return _phone; }
			set
			{
				if(value != _phone) IsModified = true;
				_phone = value;
			}
		}

		public string Fax
		{
			get { return _fax; }
			set
			{
				if(value != _fax) IsModified = true;
				_fax = value;
			}
		}

		public IList Orderses
		{
			get
			{
				if (_orderses==null)
				{
					_orderses = new ArrayList();
				}
				return _orderses;
			}
			set { _orderses = value; }
		}

		public IList CustomerCustomerTypes
		{
			get
			{
				if (_customerCustomerTypes==null)
					{
					_customerCustomerTypes = new ArrayList();
				}
				return _customerCustomerTypes;
			}
			set { _customerCustomerTypes = value; }
		}

		#endregion
		
	}
}

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
Web Developer
United States United States
Independent contract developer for .NET data-oriented systems.

not much to say about myself but feel free to contact me for any inquiries and comments!

Comments and Discussions