Click here to Skip to main content
15,892,809 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>
	/// Employee object for NHibernate mapped table 'Employees'.
	/// </summary>
    public class Employee : EntityBase
	{
		#region Member Variables
		
		protected int _id;
		protected string _lastName;
		protected string _firstName;
		protected string _title;
		protected string _titleOfCourtesy;
		protected DateTime _birthDate;
		protected DateTime _hireDate;
		protected string _address;
		protected string _city;
		protected string _region;
		protected string _postalCode;
		protected string _country;
		protected string _homePhone;
		protected string _extension;
		protected byte[] _photo;
		protected string _notes;
		protected string _photoPath;
		protected Employee _reportsTo;
		protected IList _reportsToEmployeeses;
		protected IList _orderses;
		protected IList _employeeTerritories;

		#endregion

		#region Constructors

		public Employee() { }

		public Employee( string lastName, string firstName, string title, string titleOfCourtesy, DateTime birthDate, DateTime hireDate, string address, string city, string region, string postalCode, string country, string homePhone, string extension, byte[] photo, string notes, string photoPath, Employee reportsTo )
		{
			this._lastName = lastName;
			this._firstName = firstName;
			this._title = title;
			this._titleOfCourtesy = titleOfCourtesy;
			this._birthDate = birthDate;
			this._hireDate = hireDate;
			this._address = address;
			this._city = city;
			this._region = region;
			this._postalCode = postalCode;
			this._country = country;
			this._homePhone = homePhone;
			this._extension = extension;
			this._photo = photo;
			this._notes = notes;
			this._photoPath = photoPath;
			this._reportsTo = reportsTo;
		}

		#endregion

		#region Public Properties

		public int Id
		{
			get {return _id;}
			set {_id = value;}
		}

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

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

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

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

		public DateTime BirthDate
		{
			get { return _birthDate; }
			set { _birthDate = value; }
		}

		public DateTime HireDate
		{
			get { return _hireDate; }
			set { _hireDate = 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 HomePhone
		{
			get { return _homePhone; }
			set
			{
				if(value != _homePhone) IsModified = true;
				_homePhone = value;
			}
		}

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

		public byte[] Photo
		{
			get { return _photo; }
			set { _photo = value; }
		}

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

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

		public Employee ReportsTo
		{
			get { return _reportsTo; }
			set { _reportsTo = value; }
		}

		public IList ReportsToEmployeeses
		{
			get { return _reportsToEmployeeses; }
			set { _reportsToEmployeeses = value; }
		}

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

		public IList EmployeeTerritories
		{
			get
			{
				if (_employeeTerritories==null)
					{
					_employeeTerritories = new ArrayList();
				}
				return _employeeTerritories;
			}
			set { _employeeTerritories = 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