﻿
/*
	File generated by NetTiers templates [www.nettiers.com]
	Important: Do not modify this file. Edit the file WorkOrderRouting.cs instead.
*/

#region using directives
using System;
using System.ComponentModel;
using System.Collections;
using System.Xml.Serialization;
using System.Runtime.Serialization;

using Nettiers.AdventureWorks.Entities.Validation;
#endregion

namespace Nettiers.AdventureWorks.Entities
{
	///<summary>
	/// Work order details.	
	///</summary>
	[Serializable]
	[DataObject, CLSCompliant(true)]
	public abstract partial class WorkOrderRoutingBase : EntityBase, IWorkOrderRouting, IEntityId<WorkOrderRoutingKey>, System.IComparable, System.ICloneable, ICloneableEx, IEditableObject, IComponent, INotifyPropertyChanged
	{		
		#region Variable Declarations
		
		/// <summary>
		///  Hold the inner data of the entity.
		/// </summary>
		private WorkOrderRoutingEntityData entityData;
		
		/// <summary>
		/// 	Hold the original data of the entity, as loaded from the repository.
		/// </summary>
		private WorkOrderRoutingEntityData _originalData;
		
		/// <summary>
		/// 	Hold a backup of the inner data of the entity.
		/// </summary>
		private WorkOrderRoutingEntityData backupData; 
		
		/// <summary>
		/// 	Key used if Tracking is Enabled for the <see cref="EntityLocator" />.
		/// </summary>
		private string entityTrackingKey;
		
		/// <summary>
		/// 	Hold the parent TList&lt;entity&gt; in which this entity maybe contained.
		/// </summary>
		/// <remark>Mostly used for databinding</remark>
		[NonSerialized]
		private TList<WorkOrderRouting> parentCollection;
		
		private bool inTxn = false;
		
		/// <summary>
		/// Occurs when a value is being changed for the specified column.
		/// </summary>
		[field:NonSerialized]
		public event WorkOrderRoutingEventHandler ColumnChanging;		
		
		/// <summary>
		/// Occurs after a value has been changed for the specified column.
		/// </summary>
		[field:NonSerialized]
		public event WorkOrderRoutingEventHandler ColumnChanged;
		
		#endregion Variable Declarations
		
		#region Constructors
		///<summary>
		/// Creates a new <see cref="WorkOrderRoutingBase"/> instance.
		///</summary>
		public WorkOrderRoutingBase()
		{
			this.entityData = new WorkOrderRoutingEntityData();
			this.backupData = null;
		}		
		
		///<summary>
		/// Creates a new <see cref="WorkOrderRoutingBase"/> instance.
		///</summary>
		///<param name="_workOrderId">Primary key. Foreign key to WorkOrder.WorkOrderID.</param>
		///<param name="_productId">Primary key. Foreign key to Product.ProductID.</param>
		///<param name="_operationSequence">Primary key. Indicates the manufacturing process sequence.</param>
		///<param name="_locationId">Manufacturing location where the part is processed. Foreign key to Location.LocationID.</param>
		///<param name="_scheduledStartDate">Planned manufacturing start date.</param>
		///<param name="_scheduledEndDate">Planned manufacturing end date.</param>
		///<param name="_actualStartDate">Actual start date.</param>
		///<param name="_actualEndDate">Actual end date.</param>
		///<param name="_actualResourceHrs">Number of manufacturing hours used.</param>
		///<param name="_plannedCost">Estimated manufacturing cost.</param>
		///<param name="_actualCost">Actual manufacturing cost.</param>
		///<param name="_modifiedDate">Date and time the record was last updated.</param>
		public WorkOrderRoutingBase(System.Int32 _workOrderId, System.Int32 _productId, 
			System.Int16 _operationSequence, System.Int16 _locationId, System.DateTime _scheduledStartDate, 
			System.DateTime _scheduledEndDate, System.DateTime? _actualStartDate, System.DateTime? _actualEndDate, 
			System.Decimal? _actualResourceHrs, System.Decimal _plannedCost, System.Decimal? _actualCost, 
			System.DateTime _modifiedDate)
		{
			this.entityData = new WorkOrderRoutingEntityData();
			this.backupData = null;

			this.WorkOrderId = _workOrderId;
			this.ProductId = _productId;
			this.OperationSequence = _operationSequence;
			this.LocationId = _locationId;
			this.ScheduledStartDate = _scheduledStartDate;
			this.ScheduledEndDate = _scheduledEndDate;
			this.ActualStartDate = _actualStartDate;
			this.ActualEndDate = _actualEndDate;
			this.ActualResourceHrs = _actualResourceHrs;
			this.PlannedCost = _plannedCost;
			this.ActualCost = _actualCost;
			this.ModifiedDate = _modifiedDate;
		}
		
		///<summary>
		/// A simple factory method to create a new <see cref="WorkOrderRouting"/> instance.
		///</summary>
		///<param name="_workOrderId">Primary key. Foreign key to WorkOrder.WorkOrderID.</param>
		///<param name="_productId">Primary key. Foreign key to Product.ProductID.</param>
		///<param name="_operationSequence">Primary key. Indicates the manufacturing process sequence.</param>
		///<param name="_locationId">Manufacturing location where the part is processed. Foreign key to Location.LocationID.</param>
		///<param name="_scheduledStartDate">Planned manufacturing start date.</param>
		///<param name="_scheduledEndDate">Planned manufacturing end date.</param>
		///<param name="_actualStartDate">Actual start date.</param>
		///<param name="_actualEndDate">Actual end date.</param>
		///<param name="_actualResourceHrs">Number of manufacturing hours used.</param>
		///<param name="_plannedCost">Estimated manufacturing cost.</param>
		///<param name="_actualCost">Actual manufacturing cost.</param>
		///<param name="_modifiedDate">Date and time the record was last updated.</param>
		public static WorkOrderRouting CreateWorkOrderRouting(System.Int32 _workOrderId, System.Int32 _productId, 
			System.Int16 _operationSequence, System.Int16 _locationId, System.DateTime _scheduledStartDate, 
			System.DateTime _scheduledEndDate, System.DateTime? _actualStartDate, System.DateTime? _actualEndDate, 
			System.Decimal? _actualResourceHrs, System.Decimal _plannedCost, System.Decimal? _actualCost, 
			System.DateTime _modifiedDate)
		{
			WorkOrderRouting newWorkOrderRouting = new WorkOrderRouting();
			newWorkOrderRouting.WorkOrderId = _workOrderId;
			newWorkOrderRouting.ProductId = _productId;
			newWorkOrderRouting.OperationSequence = _operationSequence;
			newWorkOrderRouting.LocationId = _locationId;
			newWorkOrderRouting.ScheduledStartDate = _scheduledStartDate;
			newWorkOrderRouting.ScheduledEndDate = _scheduledEndDate;
			newWorkOrderRouting.ActualStartDate = _actualStartDate;
			newWorkOrderRouting.ActualEndDate = _actualEndDate;
			newWorkOrderRouting.ActualResourceHrs = _actualResourceHrs;
			newWorkOrderRouting.PlannedCost = _plannedCost;
			newWorkOrderRouting.ActualCost = _actualCost;
			newWorkOrderRouting.ModifiedDate = _modifiedDate;
			return newWorkOrderRouting;
		}
				
		#endregion Constructors
			
		#region Properties	
		
		#region Data Properties		
		/// <summary>
		/// 	Gets or sets the WorkOrderId property. 
		///		Primary key. Foreign key to WorkOrder.WorkOrderID.
		/// </summary>
		/// <value>This type is int.</value>
		/// <remarks>
		/// This property can not be set to null. 
		/// </remarks>




		[DescriptionAttribute(@"Primary key. Foreign key to WorkOrder.WorkOrderID."), System.ComponentModel.Bindable( System.ComponentModel.BindableSupport.Yes)]
		[DataObjectField(true, false, false)]
		public virtual System.Int32 WorkOrderId
		{
			get
			{
				return this.entityData.WorkOrderId; 
			}
			
			set
			{
				if (this.entityData.WorkOrderId == value)
					return;
				
                OnPropertyChanging("WorkOrderId");                    
				OnColumnChanging(WorkOrderRoutingColumn.WorkOrderId, this.entityData.WorkOrderId);
				this.entityData.WorkOrderId = value;
				this.EntityId.WorkOrderId = value;
				if (this.EntityState == EntityState.Unchanged)
					this.EntityState = EntityState.Changed;
				OnColumnChanged(WorkOrderRoutingColumn.WorkOrderId, this.entityData.WorkOrderId);
				OnPropertyChanged("WorkOrderId");
			}
		}
		
		/// <summary>
		/// 	Get the original value of the WorkOrderID property.
		///		Primary key. Foreign key to WorkOrder.WorkOrderID.
		/// </summary>
		/// <remarks>This is the original value of the WorkOrderID property.</remarks>
		/// <value>This type is int</value>
		[BrowsableAttribute(false)/*, XmlIgnoreAttribute()*/]
		public  virtual System.Int32 OriginalWorkOrderId
		{
			get { return this.entityData.OriginalWorkOrderId; }
			set { this.entityData.OriginalWorkOrderId = value; }
		}
		
		/// <summary>
		/// 	Gets or sets the ProductId property. 
		///		Primary key. Foreign key to Product.ProductID.
		/// </summary>
		/// <value>This type is int.</value>
		/// <remarks>
		/// This property can not be set to null. 
		/// </remarks>




		[DescriptionAttribute(@"Primary key. Foreign key to Product.ProductID."), System.ComponentModel.Bindable( System.ComponentModel.BindableSupport.Yes)]
		[DataObjectField(true, false, false)]
		public virtual System.Int32 ProductId
		{
			get
			{
				return this.entityData.ProductId; 
			}
			
			set
			{
				if (this.entityData.ProductId == value)
					return;
				
                OnPropertyChanging("ProductId");                    
				OnColumnChanging(WorkOrderRoutingColumn.ProductId, this.entityData.ProductId);
				this.entityData.ProductId = value;
				this.EntityId.ProductId = value;
				if (this.EntityState == EntityState.Unchanged)
					this.EntityState = EntityState.Changed;
				OnColumnChanged(WorkOrderRoutingColumn.ProductId, this.entityData.ProductId);
				OnPropertyChanged("ProductId");
			}
		}
		
		/// <summary>
		/// 	Get the original value of the ProductID property.
		///		Primary key. Foreign key to Product.ProductID.
		/// </summary>
		/// <remarks>This is the original value of the ProductID property.</remarks>
		/// <value>This type is int</value>
		[BrowsableAttribute(false)/*, XmlIgnoreAttribute()*/]
		public  virtual System.Int32 OriginalProductId
		{
			get { return this.entityData.OriginalProductId; }
			set { this.entityData.OriginalProductId = value; }
		}
		
		/// <summary>
		/// 	Gets or sets the OperationSequence property. 
		///		Primary key. Indicates the manufacturing process sequence.
		/// </summary>
		/// <value>This type is smallint.</value>
		/// <remarks>
		/// This property can not be set to null. 
		/// </remarks>




		[DescriptionAttribute(@"Primary key. Indicates the manufacturing process sequence."), System.ComponentModel.Bindable( System.ComponentModel.BindableSupport.Yes)]
		[DataObjectField(true, false, false)]
		public virtual System.Int16 OperationSequence
		{
			get
			{
				return this.entityData.OperationSequence; 
			}
			
			set
			{
				if (this.entityData.OperationSequence == value)
					return;
				
                OnPropertyChanging("OperationSequence");                    
				OnColumnChanging(WorkOrderRoutingColumn.OperationSequence, this.entityData.OperationSequence);
				this.entityData.OperationSequence = value;
				this.EntityId.OperationSequence = value;
				if (this.EntityState == EntityState.Unchanged)
					this.EntityState = EntityState.Changed;
				OnColumnChanged(WorkOrderRoutingColumn.OperationSequence, this.entityData.OperationSequence);
				OnPropertyChanged("OperationSequence");
			}
		}
		
		/// <summary>
		/// 	Get the original value of the OperationSequence property.
		///		Primary key. Indicates the manufacturing process sequence.
		/// </summary>
		/// <remarks>This is the original value of the OperationSequence property.</remarks>
		/// <value>This type is smallint</value>
		[BrowsableAttribute(false)/*, XmlIgnoreAttribute()*/]
		public  virtual System.Int16 OriginalOperationSequence
		{
			get { return this.entityData.OriginalOperationSequence; }
			set { this.entityData.OriginalOperationSequence = value; }
		}
		
		/// <summary>
		/// 	Gets or sets the LocationId property. 
		///		Manufacturing location where the part is processed. Foreign key to Location.LocationID.
		/// </summary>
		/// <value>This type is smallint.</value>
		/// <remarks>
		/// This property can not be set to null. 
		/// </remarks>




		[DescriptionAttribute(@"Manufacturing location where the part is processed. Foreign key to Location.LocationID."), System.ComponentModel.Bindable( System.ComponentModel.BindableSupport.Yes)]
		[DataObjectField(false, false, false)]
		public virtual System.Int16 LocationId
		{
			get
			{
				return this.entityData.LocationId; 
			}
			
			set
			{
				if (this.entityData.LocationId == value)
					return;
				
                OnPropertyChanging("LocationId");                    
				OnColumnChanging(WorkOrderRoutingColumn.LocationId, this.entityData.LocationId);
				this.entityData.LocationId = value;
				if (this.EntityState == EntityState.Unchanged)
					this.EntityState = EntityState.Changed;
				OnColumnChanged(WorkOrderRoutingColumn.LocationId, this.entityData.LocationId);
				OnPropertyChanged("LocationId");
			}
		}
		
		/// <summary>
		/// 	Gets or sets the ScheduledStartDate property. 
		///		Planned manufacturing start date.
		/// </summary>
		/// <value>This type is datetime.</value>
		/// <remarks>
		/// This property can not be set to null. 
		/// </remarks>




		[DescriptionAttribute(@"Planned manufacturing start date."), System.ComponentModel.Bindable( System.ComponentModel.BindableSupport.Yes)]
		[DataObjectField(false, false, false)]
		public virtual System.DateTime ScheduledStartDate
		{
			get
			{
				return this.entityData.ScheduledStartDate; 
			}
			
			set
			{
				if (this.entityData.ScheduledStartDate == value)
					return;
				
                OnPropertyChanging("ScheduledStartDate");                    
				OnColumnChanging(WorkOrderRoutingColumn.ScheduledStartDate, this.entityData.ScheduledStartDate);
				this.entityData.ScheduledStartDate = value;
				if (this.EntityState == EntityState.Unchanged)
					this.EntityState = EntityState.Changed;
				OnColumnChanged(WorkOrderRoutingColumn.ScheduledStartDate, this.entityData.ScheduledStartDate);
				OnPropertyChanged("ScheduledStartDate");
			}
		}
		
		/// <summary>
		/// 	Gets or sets the ScheduledEndDate property. 
		///		Planned manufacturing end date.
		/// </summary>
		/// <value>This type is datetime.</value>
		/// <remarks>
		/// This property can not be set to null. 
		/// </remarks>




		[DescriptionAttribute(@"Planned manufacturing end date."), System.ComponentModel.Bindable( System.ComponentModel.BindableSupport.Yes)]
		[DataObjectField(false, false, false)]
		public virtual System.DateTime ScheduledEndDate
		{
			get
			{
				return this.entityData.ScheduledEndDate; 
			}
			
			set
			{
				if (this.entityData.ScheduledEndDate == value)
					return;
				
                OnPropertyChanging("ScheduledEndDate");                    
				OnColumnChanging(WorkOrderRoutingColumn.ScheduledEndDate, this.entityData.ScheduledEndDate);
				this.entityData.ScheduledEndDate = value;
				if (this.EntityState == EntityState.Unchanged)
					this.EntityState = EntityState.Changed;
				OnColumnChanged(WorkOrderRoutingColumn.ScheduledEndDate, this.entityData.ScheduledEndDate);
				OnPropertyChanged("ScheduledEndDate");
			}
		}
		
		/// <summary>
		/// 	Gets or sets the ActualStartDate property. 
		///		Actual start date.
		/// </summary>
		/// <value>This type is datetime.</value>
		/// <remarks>
		/// This property can be set to null. 
		/// If this column is null, this property will return DateTime.MinValue. It is up to the developer
		/// to check the value of IsActualStartDateNull() and perform business logic appropriately.
		/// </remarks>




		[DescriptionAttribute(@"Actual start date."), System.ComponentModel.Bindable( System.ComponentModel.BindableSupport.Yes)]
		[DataObjectField(false, false, true)]
		public virtual System.DateTime? ActualStartDate
		{
			get
			{
				return this.entityData.ActualStartDate; 
			}
			
			set
			{
				if (this.entityData.ActualStartDate == value)
					return;
				
                OnPropertyChanging("ActualStartDate");                    
				OnColumnChanging(WorkOrderRoutingColumn.ActualStartDate, this.entityData.ActualStartDate);
				this.entityData.ActualStartDate = value;
				if (this.EntityState == EntityState.Unchanged)
					this.EntityState = EntityState.Changed;
				OnColumnChanged(WorkOrderRoutingColumn.ActualStartDate, this.entityData.ActualStartDate);
				OnPropertyChanged("ActualStartDate");
			}
		}
		
		/// <summary>
		/// 	Gets or sets the ActualEndDate property. 
		///		Actual end date.
		/// </summary>
		/// <value>This type is datetime.</value>
		/// <remarks>
		/// This property can be set to null. 
		/// If this column is null, this property will return DateTime.MinValue. It is up to the developer
		/// to check the value of IsActualEndDateNull() and perform business logic appropriately.
		/// </remarks>




		[DescriptionAttribute(@"Actual end date."), System.ComponentModel.Bindable( System.ComponentModel.BindableSupport.Yes)]
		[DataObjectField(false, false, true)]
		public virtual System.DateTime? ActualEndDate
		{
			get
			{
				return this.entityData.ActualEndDate; 
			}
			
			set
			{
				if (this.entityData.ActualEndDate == value)
					return;
				
                OnPropertyChanging("ActualEndDate");                    
				OnColumnChanging(WorkOrderRoutingColumn.ActualEndDate, this.entityData.ActualEndDate);
				this.entityData.ActualEndDate = value;
				if (this.EntityState == EntityState.Unchanged)
					this.EntityState = EntityState.Changed;
				OnColumnChanged(WorkOrderRoutingColumn.ActualEndDate, this.entityData.ActualEndDate);
				OnPropertyChanged("ActualEndDate");
			}
		}
		
		/// <summary>
		/// 	Gets or sets the ActualResourceHrs property. 
		///		Number of manufacturing hours used.
		/// </summary>
		/// <value>This type is decimal.</value>
		/// <remarks>
		/// This property can be set to null. 
		/// If this column is null, this property will return 0.0m. It is up to the developer
		/// to check the value of IsActualResourceHrsNull() and perform business logic appropriately.
		/// </remarks>




		[DescriptionAttribute(@"Number of manufacturing hours used."), System.ComponentModel.Bindable( System.ComponentModel.BindableSupport.Yes)]
		[DataObjectField(false, false, true)]
		public virtual System.Decimal? ActualResourceHrs
		{
			get
			{
				return this.entityData.ActualResourceHrs; 
			}
			
			set
			{
				if (this.entityData.ActualResourceHrs == value)
					return;
				
                OnPropertyChanging("ActualResourceHrs");                    
				OnColumnChanging(WorkOrderRoutingColumn.ActualResourceHrs, this.entityData.ActualResourceHrs);
				this.entityData.ActualResourceHrs = value;
				if (this.EntityState == EntityState.Unchanged)
					this.EntityState = EntityState.Changed;
				OnColumnChanged(WorkOrderRoutingColumn.ActualResourceHrs, this.entityData.ActualResourceHrs);
				OnPropertyChanged("ActualResourceHrs");
			}
		}
		
		/// <summary>
		/// 	Gets or sets the PlannedCost property. 
		///		Estimated manufacturing cost.
		/// </summary>
		/// <value>This type is money.</value>
		/// <remarks>
		/// This property can not be set to null. 
		/// </remarks>




		[DescriptionAttribute(@"Estimated manufacturing cost."), System.ComponentModel.Bindable( System.ComponentModel.BindableSupport.Yes)]
		[DataObjectField(false, false, false)]
		public virtual System.Decimal PlannedCost
		{
			get
			{
				return this.entityData.PlannedCost; 
			}
			
			set
			{
				if (this.entityData.PlannedCost == value)
					return;
				
                OnPropertyChanging("PlannedCost");                    
				OnColumnChanging(WorkOrderRoutingColumn.PlannedCost, this.entityData.PlannedCost);
				this.entityData.PlannedCost = value;
				if (this.EntityState == EntityState.Unchanged)
					this.EntityState = EntityState.Changed;
				OnColumnChanged(WorkOrderRoutingColumn.PlannedCost, this.entityData.PlannedCost);
				OnPropertyChanged("PlannedCost");
			}
		}
		
		/// <summary>
		/// 	Gets or sets the ActualCost property. 
		///		Actual manufacturing cost.
		/// </summary>
		/// <value>This type is money.</value>
		/// <remarks>
		/// This property can be set to null. 
		/// If this column is null, this property will return 0. It is up to the developer
		/// to check the value of IsActualCostNull() and perform business logic appropriately.
		/// </remarks>




		[DescriptionAttribute(@"Actual manufacturing cost."), System.ComponentModel.Bindable( System.ComponentModel.BindableSupport.Yes)]
		[DataObjectField(false, false, true)]
		public virtual System.Decimal? ActualCost
		{
			get
			{
				return this.entityData.ActualCost; 
			}
			
			set
			{
				if (this.entityData.ActualCost == value)
					return;
				
                OnPropertyChanging("ActualCost");                    
				OnColumnChanging(WorkOrderRoutingColumn.ActualCost, this.entityData.ActualCost);
				this.entityData.ActualCost = value;
				if (this.EntityState == EntityState.Unchanged)
					this.EntityState = EntityState.Changed;
				OnColumnChanged(WorkOrderRoutingColumn.ActualCost, this.entityData.ActualCost);
				OnPropertyChanged("ActualCost");
			}
		}
		
		/// <summary>
		/// 	Gets or sets the ModifiedDate property. 
		///		Date and time the record was last updated.
		/// </summary>
		/// <value>This type is datetime.</value>
		/// <remarks>
		/// This property can not be set to null. 
		/// </remarks>




		[DescriptionAttribute(@"Date and time the record was last updated."), System.ComponentModel.Bindable( System.ComponentModel.BindableSupport.Yes)]
		[DataObjectField(false, false, false)]
		public virtual System.DateTime ModifiedDate
		{
			get
			{
				return this.entityData.ModifiedDate; 
			}
			
			set
			{
				if (this.entityData.ModifiedDate == value)
					return;
				
                OnPropertyChanging("ModifiedDate");                    
				OnColumnChanging(WorkOrderRoutingColumn.ModifiedDate, this.entityData.ModifiedDate);
				this.entityData.ModifiedDate = value;
				if (this.EntityState == EntityState.Unchanged)
					this.EntityState = EntityState.Changed;
				OnColumnChanged(WorkOrderRoutingColumn.ModifiedDate, this.entityData.ModifiedDate);
				OnPropertyChanged("ModifiedDate");
			}
		}
		
		#endregion Data Properties		

		#region Source Foreign Key Property
				
		/// <summary>
		/// Gets or sets the source <see cref="Location"/>.
		/// </summary>
		/// <value>The source Location for LocationId.</value>
        [XmlIgnore()]
		[Browsable(false), System.ComponentModel.Bindable(System.ComponentModel.BindableSupport.Yes)]
		public virtual Location LocationIdSource
      	{
            get { return entityData.LocationIdSource; }
            set { entityData.LocationIdSource = value; }
      	}
		/// <summary>
		/// Gets or sets the source <see cref="WorkOrder"/>.
		/// </summary>
		/// <value>The source WorkOrder for WorkOrderId.</value>
        [XmlIgnore()]
		[Browsable(false), System.ComponentModel.Bindable(System.ComponentModel.BindableSupport.Yes)]
		public virtual WorkOrder WorkOrderIdSource
      	{
            get { return entityData.WorkOrderIdSource; }
            set { entityData.WorkOrderIdSource = value; }
      	}
		#endregion
		
		#region Children Collections
		#endregion Children Collections
		
		#endregion
		#region Validation
		
		/// <summary>
		/// Assigns validation rules to this object based on model definition.
		/// </summary>
		/// <remarks>This method overrides the base class to add schema related validation.</remarks>
		protected override void AddValidationRules()
		{
			//Validation rules based on database schema.
		}
   		#endregion
		
		#region Table Meta Data
		/// <summary>
		///		The name of the underlying database table.
		/// </summary>
		[BrowsableAttribute(false), XmlIgnoreAttribute()]
		public override string TableName
		{
			get { return "WorkOrderRouting"; }
		}
		
		/// <summary>
		///		The name of the underlying database table's columns.
		/// </summary>
		[BrowsableAttribute(false), XmlIgnoreAttribute()]
		public override string[] TableColumns
		{
			get
			{
				return new string[] {"WorkOrderID", "ProductID", "OperationSequence", "LocationID", "ScheduledStartDate", "ScheduledEndDate", "ActualStartDate", "ActualEndDate", "ActualResourceHrs", "PlannedCost", "ActualCost", "ModifiedDate"};
			}
		}
		#endregion 
		
		#region IEditableObject
		
		#region  CancelAddNew Event
		/// <summary>
        /// The delegate for the CancelAddNew event.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
		public delegate void CancelAddNewEventHandler(object sender, EventArgs e);
    
    	/// <summary>
		/// The CancelAddNew event.
		/// </summary>
		[field:NonSerialized]
		public event CancelAddNewEventHandler CancelAddNew ;

		/// <summary>
        /// Called when [cancel add new].
        /// </summary>
        public void OnCancelAddNew()
        {    
			if (!SuppressEntityEvents)
			{
	            CancelAddNewEventHandler handler = CancelAddNew ;
            	if (handler != null)
	            {    
    	            handler(this, EventArgs.Empty) ;
        	    }
	        }
        }
		#endregion 
		
		/// <summary>
		/// Begins an edit on an object.
		/// </summary>
		void IEditableObject.BeginEdit() 
	    {
	        //Console.WriteLine("Start BeginEdit");
	        if (!inTxn) 
	        {
	            this.backupData = this.entityData.Clone() as WorkOrderRoutingEntityData;
	            inTxn = true;
	            //Console.WriteLine("BeginEdit");
	        }
	        //Console.WriteLine("End BeginEdit");
	    }
	
		/// <summary>
		/// Discards changes since the last <c>BeginEdit</c> call.
		/// </summary>
	    void IEditableObject.CancelEdit() 
	    {
	        //Console.WriteLine("Start CancelEdit");
	        if (this.inTxn) 
	        {
	            this.entityData = this.backupData;
	            this.backupData = null;
				this.inTxn = false;

				if (this.bindingIsNew)
	        	//if (this.EntityState == EntityState.Added)
	        	{
					if (this.parentCollection != null)
						this.parentCollection.Remove( (WorkOrderRouting) this ) ;
				}	            
	        }
	        //Console.WriteLine("End CancelEdit");
	    }
	
		/// <summary>
		/// Pushes changes since the last <c>BeginEdit</c> or <c>IBindingList.AddNew</c> call into the underlying object.
		/// </summary>
	    void IEditableObject.EndEdit() 
	    {
	        //Console.WriteLine("Start EndEdit" + this.custData.id + this.custData.lastName);
	        if (this.inTxn) 
	        {
	            this.backupData = null;
				if (this.IsDirty) 
				{
					if (this.bindingIsNew) {
						this.EntityState = EntityState.Added;
						this.bindingIsNew = false ;
					}
					else
						if (this.EntityState == EntityState.Unchanged) 
							this.EntityState = EntityState.Changed ;
				}

				this.bindingIsNew = false ;
	            this.inTxn = false;	            
	        }
	        //Console.WriteLine("End EndEdit");
	    }
	    
	    /// <summary>
        /// Gets or sets the parent collection of this current entity, if available.
        /// </summary>
        /// <value>The parent collection.</value>
	    [XmlIgnore]
		[Browsable(false)]
	    public override object ParentCollection
	    {
	        get 
	        {
	            return this.parentCollection;
	        }
	        set 
	        {
	            this.parentCollection = value as TList<WorkOrderRouting>;
	        }
	    }
	    
	    /// <summary>
        /// Called when the entity is changed.
        /// </summary>
	    private void OnEntityChanged() 
	    {
	        if (!SuppressEntityEvents && !inTxn && this.parentCollection != null) 
	        {
	            this.parentCollection.EntityChanged(this as WorkOrderRouting);
	        }
	    }


		#endregion
		
		#region ICloneable Members
		///<summary>
		///  Returns a Typed WorkOrderRouting Entity 
		///</summary>
		protected virtual WorkOrderRouting Copy(IDictionary existingCopies)
		{
			if (existingCopies == null)
			{
				// This is the root of the tree to be copied!
				existingCopies = new Hashtable();
			}

			//shallow copy entity
			WorkOrderRouting copy = new WorkOrderRouting();
			existingCopies.Add(this, copy);
			copy.SuppressEntityEvents = true;
				copy.WorkOrderId = this.WorkOrderId;
					copy.OriginalWorkOrderId = this.OriginalWorkOrderId;
				copy.ProductId = this.ProductId;
					copy.OriginalProductId = this.OriginalProductId;
				copy.OperationSequence = this.OperationSequence;
					copy.OriginalOperationSequence = this.OriginalOperationSequence;
				copy.LocationId = this.LocationId;
				copy.ScheduledStartDate = this.ScheduledStartDate;
				copy.ScheduledEndDate = this.ScheduledEndDate;
				copy.ActualStartDate = this.ActualStartDate;
				copy.ActualEndDate = this.ActualEndDate;
				copy.ActualResourceHrs = this.ActualResourceHrs;
				copy.PlannedCost = this.PlannedCost;
				copy.ActualCost = this.ActualCost;
				copy.ModifiedDate = this.ModifiedDate;
			
			if (this.LocationIdSource != null && existingCopies.Contains(this.LocationIdSource))
				copy.LocationIdSource = existingCopies[this.LocationIdSource] as Location;
			else
				copy.LocationIdSource = MakeCopyOf(this.LocationIdSource, existingCopies) as Location;
			if (this.WorkOrderIdSource != null && existingCopies.Contains(this.WorkOrderIdSource))
				copy.WorkOrderIdSource = existingCopies[this.WorkOrderIdSource] as WorkOrder;
			else
				copy.WorkOrderIdSource = MakeCopyOf(this.WorkOrderIdSource, existingCopies) as WorkOrder;
		
			copy.EntityState = this.EntityState;
			copy.SuppressEntityEvents = false;
			return copy;
		}		
		
		
		
		///<summary>
		///  Returns a Typed WorkOrderRouting Entity 
		///</summary>
		public virtual WorkOrderRouting Copy()
		{
			return this.Copy(null);	
		}
		
		///<summary>
		/// ICloneable.Clone() Member, returns the Shallow Copy of this entity.
		///</summary>
		public object Clone()
		{
			return this.Copy(null);
		}
		
		///<summary>
		/// ICloneableEx.Clone() Member, returns the Shallow Copy of this entity.
		///</summary>
		public object Clone(IDictionary existingCopies)
		{
			return this.Copy(existingCopies);
		}
		
		///<summary>
		/// Returns a deep copy of the child collection object passed in.
		///</summary>
		public static object MakeCopyOf(object x)
		{
			if (x == null)
				return null;
				
			if (x is ICloneable)
			{
				// Return a deep copy of the object
				return ((ICloneable)x).Clone();
			}
			else
				throw new System.NotSupportedException("Object Does Not Implement the ICloneable Interface.");
		}
		
		///<summary>
		/// Returns a deep copy of the child collection object passed in.
		///</summary>
		public static object MakeCopyOf(object x, IDictionary existingCopies)
		{
			if (x == null)
				return null;
			
			if (x is ICloneableEx)
			{
				// Return a deep copy of the object
				return ((ICloneableEx)x).Clone(existingCopies);
			}
			else if (x is ICloneable)
			{
				// Return a deep copy of the object
				return ((ICloneable)x).Clone();
			}
			else
				throw new System.NotSupportedException("Object Does Not Implement the ICloneable or IClonableEx Interface.");
		}
		
		
		///<summary>
		///  Returns a Typed WorkOrderRouting Entity which is a deep copy of the current entity.
		///</summary>
		public virtual WorkOrderRouting DeepCopy()
		{
			return EntityHelper.Clone<WorkOrderRouting>(this as WorkOrderRouting);	
		}
		#endregion
		
		#region Methods	
			
		///<summary>
		/// Revert all changes and restore original values.
		///</summary>
		public override void CancelChanges()
		{
			IEditableObject obj = (IEditableObject) this;
			obj.CancelEdit();

			this.entityData = null;
			if (this._originalData != null)
			{
				this.entityData = this._originalData.Clone() as WorkOrderRoutingEntityData;
			}
			else
			{
				//Since this had no _originalData, then just reset the entityData with a new one.  entityData cannot be null.
				this.entityData = new WorkOrderRoutingEntityData();
			}
		}	
		
		/// <summary>
		/// Accepts the changes made to this object.
		/// </summary>
		/// <remarks>
		/// After calling this method, properties: IsDirty, IsNew are false. IsDeleted flag remains unchanged as it is handled by the parent List.
		/// </remarks>
		public override void AcceptChanges()
		{
			base.AcceptChanges();

			// we keep of the original version of the data
			this._originalData = null;
			this._originalData = this.entityData.Clone() as WorkOrderRoutingEntityData;
		}
		
		#region Comparision with original data
		
		/// <summary>
		/// Determines whether the property value has changed from the original data.
		/// </summary>
		/// <param name="column">The column.</param>
		/// <returns>
		/// 	<c>true</c> if the property value has changed; otherwise, <c>false</c>.
		/// </returns>
		public bool IsPropertyChanged(WorkOrderRoutingColumn column)
		{
			switch(column)
			{
					case WorkOrderRoutingColumn.WorkOrderId:
					return entityData.WorkOrderId != _originalData.WorkOrderId;
					case WorkOrderRoutingColumn.ProductId:
					return entityData.ProductId != _originalData.ProductId;
					case WorkOrderRoutingColumn.OperationSequence:
					return entityData.OperationSequence != _originalData.OperationSequence;
					case WorkOrderRoutingColumn.LocationId:
					return entityData.LocationId != _originalData.LocationId;
					case WorkOrderRoutingColumn.ScheduledStartDate:
					return entityData.ScheduledStartDate != _originalData.ScheduledStartDate;
					case WorkOrderRoutingColumn.ScheduledEndDate:
					return entityData.ScheduledEndDate != _originalData.ScheduledEndDate;
					case WorkOrderRoutingColumn.ActualStartDate:
					return entityData.ActualStartDate != _originalData.ActualStartDate;
					case WorkOrderRoutingColumn.ActualEndDate:
					return entityData.ActualEndDate != _originalData.ActualEndDate;
					case WorkOrderRoutingColumn.ActualResourceHrs:
					return entityData.ActualResourceHrs != _originalData.ActualResourceHrs;
					case WorkOrderRoutingColumn.PlannedCost:
					return entityData.PlannedCost != _originalData.PlannedCost;
					case WorkOrderRoutingColumn.ActualCost:
					return entityData.ActualCost != _originalData.ActualCost;
					case WorkOrderRoutingColumn.ModifiedDate:
					return entityData.ModifiedDate != _originalData.ModifiedDate;
			
				default:
					return false;
			}
		}
		
		/// <summary>
		/// Determines whether the property value has changed from the original data.
		/// </summary>
		/// <param name="columnName">The column name.</param>
		/// <returns>
		/// 	<c>true</c> if the property value has changed; otherwise, <c>false</c>.
		/// </returns>
		public override bool IsPropertyChanged(string columnName)
		{
			return 	IsPropertyChanged(EntityHelper.GetEnumValue< WorkOrderRoutingColumn >(columnName));
		}
		
		/// <summary>
		/// Determines whether the data has changed from original.
		/// </summary>
		/// <returns>
		/// 	<c>true</c> if data has changed; otherwise, <c>false</c>.
		/// </returns>
		public bool HasDataChanged()
		{
			bool result = false;
			result = result || entityData.WorkOrderId != _originalData.WorkOrderId;
			result = result || entityData.ProductId != _originalData.ProductId;
			result = result || entityData.OperationSequence != _originalData.OperationSequence;
			result = result || entityData.LocationId != _originalData.LocationId;
			result = result || entityData.ScheduledStartDate != _originalData.ScheduledStartDate;
			result = result || entityData.ScheduledEndDate != _originalData.ScheduledEndDate;
			result = result || entityData.ActualStartDate != _originalData.ActualStartDate;
			result = result || entityData.ActualEndDate != _originalData.ActualEndDate;
			result = result || entityData.ActualResourceHrs != _originalData.ActualResourceHrs;
			result = result || entityData.PlannedCost != _originalData.PlannedCost;
			result = result || entityData.ActualCost != _originalData.ActualCost;
			result = result || entityData.ModifiedDate != _originalData.ModifiedDate;
			return result;
		}	
		
		///<summary>
		///  Returns a WorkOrderRouting Entity with the original data.
		///</summary>
		public WorkOrderRouting GetOriginalEntity()
		{
			if (_originalData != null)
				return CreateWorkOrderRouting(
				_originalData.WorkOrderId,
				_originalData.ProductId,
				_originalData.OperationSequence,
				_originalData.LocationId,
				_originalData.ScheduledStartDate,
				_originalData.ScheduledEndDate,
				_originalData.ActualStartDate,
				_originalData.ActualEndDate,
				_originalData.ActualResourceHrs,
				_originalData.PlannedCost,
				_originalData.ActualCost,
				_originalData.ModifiedDate
				);
				
			return (WorkOrderRouting)this.Clone();
		}
		#endregion
	
	#region Value Semantics Instance Equality
        ///<summary>
        /// Returns a value indicating whether this instance is equal to a specified object using value semantics.
        ///</summary>
        ///<param name="Object1">An object to compare to this instance.</param>
        ///<returns>true if Object1 is a <see cref="WorkOrderRoutingBase"/> and has the same value as this instance; otherwise, false.</returns>
        public override bool Equals(object Object1)
        {
			// Cast exception if Object1 is null or DbNull
			if (Object1 != null && Object1 != DBNull.Value && Object1 is WorkOrderRoutingBase)
				return ValueEquals(this, (WorkOrderRoutingBase)Object1);
			else
				return false;
        }

        /// <summary>
		/// Serves as a hash function for a particular type, suitable for use in hashing algorithms and data structures like a hash table.
        /// Provides a hash function that is appropriate for <see cref="WorkOrderRoutingBase"/> class 
        /// and that ensures a better distribution in the hash table
        /// </summary>
        /// <returns>number (hash code) that corresponds to the value of an object</returns>
        public override int GetHashCode()
        {
			return this.WorkOrderId.GetHashCode() ^ 
					this.ProductId.GetHashCode() ^ 
					this.OperationSequence.GetHashCode() ^ 
					this.LocationId.GetHashCode() ^ 
					this.ScheduledStartDate.GetHashCode() ^ 
					this.ScheduledEndDate.GetHashCode() ^ 
					((this.ActualStartDate == null) ? string.Empty : this.ActualStartDate.ToString()).GetHashCode() ^ 
					((this.ActualEndDate == null) ? string.Empty : this.ActualEndDate.ToString()).GetHashCode() ^ 
					((this.ActualResourceHrs == null) ? string.Empty : this.ActualResourceHrs.ToString()).GetHashCode() ^ 
					this.PlannedCost.GetHashCode() ^ 
					((this.ActualCost == null) ? string.Empty : this.ActualCost.ToString()).GetHashCode() ^ 
					this.ModifiedDate.GetHashCode();
        }
		
		///<summary>
		/// Returns a value indicating whether this instance is equal to a specified object using value semantics.
		///</summary>
		///<param name="toObject">An object to compare to this instance.</param>
		///<returns>true if toObject is a <see cref="WorkOrderRoutingBase"/> and has the same value as this instance; otherwise, false.</returns>
		public virtual bool Equals(WorkOrderRoutingBase toObject)
		{
			if (toObject == null)
				return false;
			return ValueEquals(this, toObject);
		}
		#endregion
		
		///<summary>
		/// Determines whether the specified <see cref="WorkOrderRoutingBase"/> instances are considered equal using value semantics.
		///</summary>
		///<param name="Object1">The first <see cref="WorkOrderRoutingBase"/> to compare.</param>
		///<param name="Object2">The second <see cref="WorkOrderRoutingBase"/> to compare. </param>
		///<returns>true if Object1 is the same instance as Object2 or if both are null references or if objA.Equals(objB) returns true; otherwise, false.</returns>
		public static bool ValueEquals(WorkOrderRoutingBase Object1, WorkOrderRoutingBase Object2)
		{
			// both are null
			if (Object1 == null && Object2 == null)
				return true;

			// one or the other is null, but not both
			if (Object1 == null ^ Object2 == null)
				return false;
				
			bool equal = true;
			if (Object1.WorkOrderId != Object2.WorkOrderId)
				equal = false;
			if (Object1.ProductId != Object2.ProductId)
				equal = false;
			if (Object1.OperationSequence != Object2.OperationSequence)
				equal = false;
			if (Object1.LocationId != Object2.LocationId)
				equal = false;
			if (Object1.ScheduledStartDate != Object2.ScheduledStartDate)
				equal = false;
			if (Object1.ScheduledEndDate != Object2.ScheduledEndDate)
				equal = false;
			if ( Object1.ActualStartDate != null && Object2.ActualStartDate != null )
			{
				if (Object1.ActualStartDate != Object2.ActualStartDate)
					equal = false;
			}
			else if (Object1.ActualStartDate == null ^ Object2.ActualStartDate == null )
			{
				equal = false;
			}
			if ( Object1.ActualEndDate != null && Object2.ActualEndDate != null )
			{
				if (Object1.ActualEndDate != Object2.ActualEndDate)
					equal = false;
			}
			else if (Object1.ActualEndDate == null ^ Object2.ActualEndDate == null )
			{
				equal = false;
			}
			if ( Object1.ActualResourceHrs != null && Object2.ActualResourceHrs != null )
			{
				if (Object1.ActualResourceHrs != Object2.ActualResourceHrs)
					equal = false;
			}
			else if (Object1.ActualResourceHrs == null ^ Object2.ActualResourceHrs == null )
			{
				equal = false;
			}
			if (Object1.PlannedCost != Object2.PlannedCost)
				equal = false;
			if ( Object1.ActualCost != null && Object2.ActualCost != null )
			{
				if (Object1.ActualCost != Object2.ActualCost)
					equal = false;
			}
			else if (Object1.ActualCost == null ^ Object2.ActualCost == null )
			{
				equal = false;
			}
			if (Object1.ModifiedDate != Object2.ModifiedDate)
				equal = false;
					
			return equal;
		}
		
		#endregion
		
		#region IComparable Members
		///<summary>
		/// Compares this instance to a specified object and returns an indication of their relative values.
		///<param name="obj">An object to compare to this instance, or a null reference (Nothing in Visual Basic).</param>
		///</summary>
		///<returns>A signed integer that indicates the relative order of this instance and obj.</returns>
		public virtual int CompareTo(object obj)
		{
			throw new NotImplementedException();
			//return this. GetPropertyName(SourceTable.PrimaryKey.MemberColumns[0]) .CompareTo(((WorkOrderRoutingBase)obj).GetPropertyName(SourceTable.PrimaryKey.MemberColumns[0]));
		}
		
		/*
		// static method to get a Comparer object
        public static WorkOrderRoutingComparer GetComparer()
        {
            return new WorkOrderRoutingComparer();
        }
        */

        // Comparer delegates back to WorkOrderRouting
        // Employee uses the integer's default
        // CompareTo method
        /*
        public int CompareTo(Item rhs)
        {
            return this.Id.CompareTo(rhs.Id);
        }
        */

/*
        // Special implementation to be called by custom comparer
        public int CompareTo(WorkOrderRouting rhs, WorkOrderRoutingColumn which)
        {
            switch (which)
            {
            	
            	
            	case WorkOrderRoutingColumn.WorkOrderId:
            		return this.WorkOrderId.CompareTo(rhs.WorkOrderId);
            		
            		                 
            	
            	
            	case WorkOrderRoutingColumn.ProductId:
            		return this.ProductId.CompareTo(rhs.ProductId);
            		
            		                 
            	
            	
            	case WorkOrderRoutingColumn.OperationSequence:
            		return this.OperationSequence.CompareTo(rhs.OperationSequence);
            		
            		                 
            	
            	
            	case WorkOrderRoutingColumn.LocationId:
            		return this.LocationId.CompareTo(rhs.LocationId);
            		
            		                 
            	
            	
            	case WorkOrderRoutingColumn.ScheduledStartDate:
            		return this.ScheduledStartDate.CompareTo(rhs.ScheduledStartDate);
            		
            		                 
            	
            	
            	case WorkOrderRoutingColumn.ScheduledEndDate:
            		return this.ScheduledEndDate.CompareTo(rhs.ScheduledEndDate);
            		
            		                 
            	
            	
            	case WorkOrderRoutingColumn.ActualStartDate:
            		return this.ActualStartDate.Value.CompareTo(rhs.ActualStartDate.Value);
            		
            		                 
            	
            	
            	case WorkOrderRoutingColumn.ActualEndDate:
            		return this.ActualEndDate.Value.CompareTo(rhs.ActualEndDate.Value);
            		
            		                 
            	
            	
            	case WorkOrderRoutingColumn.ActualResourceHrs:
            		return this.ActualResourceHrs.Value.CompareTo(rhs.ActualResourceHrs.Value);
            		
            		                 
            	
            	
            	case WorkOrderRoutingColumn.PlannedCost:
            		return this.PlannedCost.CompareTo(rhs.PlannedCost);
            		
            		                 
            	
            	
            	case WorkOrderRoutingColumn.ActualCost:
            		return this.ActualCost.Value.CompareTo(rhs.ActualCost.Value);
            		
            		                 
            	
            	
            	case WorkOrderRoutingColumn.ModifiedDate:
            		return this.ModifiedDate.CompareTo(rhs.ModifiedDate);
            		
            		                 
            }
            return 0;
        }
        */
	
		#endregion
		
		#region IComponent Members
		
		private ISite _site = null;

		/// <summary>
		/// Gets or Sets the site where this data is located.
		/// </summary>
		[XmlIgnore]
		[SoapIgnore]
		[Browsable(false)]
		public ISite Site
		{
			get{ return this._site; }
			set{ this._site = value; }
		}

		#endregion

		#region IDisposable Members
		
		/// <summary>
		/// Notify those that care when we dispose.
		/// </summary>
		[field:NonSerialized]
		public event System.EventHandler Disposed;

		/// <summary>
		/// Clean up. Nothing here though.
		/// </summary>
		public virtual void Dispose()
		{
			this.parentCollection = null;
			this.Dispose(true);
			GC.SuppressFinalize(this);
		}
		
		/// <summary>
		/// Clean up.
		/// </summary>
		protected virtual void Dispose(bool disposing)
		{
			if (disposing)
			{
				EventHandler handler = Disposed;
				if (handler != null)
					handler(this, EventArgs.Empty);
			}
		}
		
		#endregion
				
		#region IEntityKey<WorkOrderRoutingKey> Members
		
		// member variable for the EntityId property
		private WorkOrderRoutingKey _entityId;

		/// <summary>
		/// Gets or sets the EntityId property.
		/// </summary>
		[XmlIgnore]
		public virtual WorkOrderRoutingKey EntityId
		{
			get
			{
				if ( _entityId == null )
				{
					_entityId = new WorkOrderRoutingKey(this);
				}

				return _entityId;
			}
			set
			{
				if ( value != null )
				{
					value.Entity = this;
				}
				
				_entityId = value;
			}
		}
		
		#endregion
		
		#region EntityState
		/// <summary>
		///		Indicates state of object
		/// </summary>
		/// <remarks>0=Unchanged, 1=Added, 2=Changed</remarks>
		[BrowsableAttribute(false) , XmlIgnoreAttribute()]
		public override EntityState EntityState 
		{ 
			get{ return entityData.EntityState;	 } 
			set{ entityData.EntityState = value; } 
		}
		#endregion 
		
		#region EntityTrackingKey
		///<summary>
		/// Provides the tracking key for the <see cref="EntityLocator"/>
		///</summary>
		[XmlIgnore]
		public override string EntityTrackingKey
		{
			get
			{
				if(entityTrackingKey == null)
					entityTrackingKey = new System.Text.StringBuilder("WorkOrderRouting")
					.Append("|").Append( this.WorkOrderId.ToString())
					.Append("|").Append( this.ProductId.ToString())
					.Append("|").Append( this.OperationSequence.ToString()).ToString();
				return entityTrackingKey;
			}
			set
		    {
		        if (value != null)
                    entityTrackingKey = value;
		    }
		}
		#endregion 
		
		#region ToString Method
		
		///<summary>
		/// Returns a String that represents the current object.
		///</summary>
		public override string ToString()
		{
			return string.Format(System.Globalization.CultureInfo.InvariantCulture,
				"{13}{12}- WorkOrderId: {0}{12}- ProductId: {1}{12}- OperationSequence: {2}{12}- LocationId: {3}{12}- ScheduledStartDate: {4}{12}- ScheduledEndDate: {5}{12}- ActualStartDate: {6}{12}- ActualEndDate: {7}{12}- ActualResourceHrs: {8}{12}- PlannedCost: {9}{12}- ActualCost: {10}{12}- ModifiedDate: {11}{12}{14}", 
				this.WorkOrderId,
				this.ProductId,
				this.OperationSequence,
				this.LocationId,
				this.ScheduledStartDate,
				this.ScheduledEndDate,
				(this.ActualStartDate == null) ? string.Empty : this.ActualStartDate.ToString(),
				(this.ActualEndDate == null) ? string.Empty : this.ActualEndDate.ToString(),
				(this.ActualResourceHrs == null) ? string.Empty : this.ActualResourceHrs.ToString(),
				this.PlannedCost,
				(this.ActualCost == null) ? string.Empty : this.ActualCost.ToString(),
				this.ModifiedDate,
				System.Environment.NewLine, 
				this.GetType(),
				this.Error.Length == 0 ? string.Empty : string.Format("- Error: {0}\n",this.Error));
		}
		
		#endregion ToString Method
		
		#region Inner data class
		
	/// <summary>
	///		The data structure representation of the 'WorkOrderRouting' table.
	/// </summary>
	/// <remarks>
	/// 	This struct is generated by a tool and should never be modified.
	/// </remarks>
	[EditorBrowsable(EditorBrowsableState.Never)]
	[Serializable]
	internal protected class WorkOrderRoutingEntityData : ICloneable, ICloneableEx
	{
		#region Variable Declarations
		private EntityState currentEntityState = EntityState.Added;
		
		#region Primary key(s)
		/// <summary>			
		/// WorkOrderID : Primary key. Foreign key to WorkOrder.WorkOrderID.
		/// </summary>
		/// <remarks>Member of the primary key of the underlying table "WorkOrderRouting"</remarks>
		public System.Int32 WorkOrderId;
			
		/// <summary>
		/// keep a copy of the original so it can be used for editable primary keys.
		/// </summary>
		public System.Int32 OriginalWorkOrderId;
		
		/// <summary>			
		/// ProductID : Primary key. Foreign key to Product.ProductID.
		/// </summary>
		/// <remarks>Member of the primary key of the underlying table "WorkOrderRouting"</remarks>
		public System.Int32 ProductId;
			
		/// <summary>
		/// keep a copy of the original so it can be used for editable primary keys.
		/// </summary>
		public System.Int32 OriginalProductId;
		
		/// <summary>			
		/// OperationSequence : Primary key. Indicates the manufacturing process sequence.
		/// </summary>
		/// <remarks>Member of the primary key of the underlying table "WorkOrderRouting"</remarks>
		public System.Int16 OperationSequence;
			
		/// <summary>
		/// keep a copy of the original so it can be used for editable primary keys.
		/// </summary>
		public System.Int16 OriginalOperationSequence;
		
		#endregion
		
		#region Non Primary key(s)
		
		/// <summary>
		/// LocationID : Manufacturing location where the part is processed. Foreign key to Location.LocationID.
		/// </summary>
		public System.Int16 LocationId = (short)0;
		
		/// <summary>
		/// ScheduledStartDate : Planned manufacturing start date.
		/// </summary>
		public System.DateTime ScheduledStartDate = DateTime.MinValue;
		
		/// <summary>
		/// ScheduledEndDate : Planned manufacturing end date.
		/// </summary>
		public System.DateTime ScheduledEndDate = DateTime.MinValue;
		
		/// <summary>
		/// ActualStartDate : Actual start date.
		/// </summary>
		public System.DateTime? ActualStartDate = null;
		
		/// <summary>
		/// ActualEndDate : Actual end date.
		/// </summary>
		public System.DateTime? ActualEndDate = null;
		
		/// <summary>
		/// ActualResourceHrs : Number of manufacturing hours used.
		/// </summary>
		public System.Decimal? ActualResourceHrs = null;
		
		/// <summary>
		/// PlannedCost : Estimated manufacturing cost.
		/// </summary>
		public System.Decimal PlannedCost = 0;
		
		/// <summary>
		/// ActualCost : Actual manufacturing cost.
		/// </summary>
		public System.Decimal? ActualCost = null;
		
		/// <summary>
		/// ModifiedDate : Date and time the record was last updated.
		/// </summary>
		public System.DateTime ModifiedDate = DateTime.MinValue;
		#endregion
			
		#region Source Foreign Key Property
				
		private Location _locationIdSource = null;
		
		/// <summary>
		/// Gets or sets the source <see cref="Location"/>.
		/// </summary>
		/// <value>The source Location for LocationId.</value>
		[XmlIgnore()]
		[Browsable(false)]
		public virtual Location LocationIdSource
      	{
            get { return this._locationIdSource; }
            set { this._locationIdSource = value; }
      	}
		private WorkOrder _workOrderIdSource = null;
		
		/// <summary>
		/// Gets or sets the source <see cref="WorkOrder"/>.
		/// </summary>
		/// <value>The source WorkOrder for WorkOrderId.</value>
		[XmlIgnore()]
		[Browsable(false)]
		public virtual WorkOrder WorkOrderIdSource
      	{
            get { return this._workOrderIdSource; }
            set { this._workOrderIdSource = value; }
      	}
		#endregion
        
		#endregion Variable Declarations

		#region Data Properties

		#endregion Data Properties
		#region Clone Method

		/// <summary>
		/// Creates a new object that is a copy of the current instance.
		/// </summary>
		/// <returns>A new object that is a copy of this instance.</returns>
		public Object Clone()
		{
			WorkOrderRoutingEntityData _tmp = new WorkOrderRoutingEntityData();
						
			_tmp.WorkOrderId = this.WorkOrderId;
			_tmp.OriginalWorkOrderId = this.OriginalWorkOrderId;
			_tmp.ProductId = this.ProductId;
			_tmp.OriginalProductId = this.OriginalProductId;
			_tmp.OperationSequence = this.OperationSequence;
			_tmp.OriginalOperationSequence = this.OriginalOperationSequence;
			
			_tmp.LocationId = this.LocationId;
			_tmp.ScheduledStartDate = this.ScheduledStartDate;
			_tmp.ScheduledEndDate = this.ScheduledEndDate;
			_tmp.ActualStartDate = this.ActualStartDate;
			_tmp.ActualEndDate = this.ActualEndDate;
			_tmp.ActualResourceHrs = this.ActualResourceHrs;
			_tmp.PlannedCost = this.PlannedCost;
			_tmp.ActualCost = this.ActualCost;
			_tmp.ModifiedDate = this.ModifiedDate;
			
			#region Source Parent Composite Entities
			if (this.LocationIdSource != null)
				_tmp.LocationIdSource = MakeCopyOf(this.LocationIdSource) as Location;
			if (this.WorkOrderIdSource != null)
				_tmp.WorkOrderIdSource = MakeCopyOf(this.WorkOrderIdSource) as WorkOrder;
			#endregion
		
			#region Child Collections
			#endregion Child Collections
			
			//EntityState
			_tmp.EntityState = this.EntityState;
			
			return _tmp;
		}
		
		/// <summary>
		/// Creates a new object that is a copy of the current instance.
		/// </summary>
		/// <returns>A new object that is a copy of this instance.</returns>
		public object Clone(IDictionary existingCopies)
		{
			if (existingCopies == null)
				existingCopies = new Hashtable();
				
			WorkOrderRoutingEntityData _tmp = new WorkOrderRoutingEntityData();
						
			_tmp.WorkOrderId = this.WorkOrderId;
			_tmp.OriginalWorkOrderId = this.OriginalWorkOrderId;
			_tmp.ProductId = this.ProductId;
			_tmp.OriginalProductId = this.OriginalProductId;
			_tmp.OperationSequence = this.OperationSequence;
			_tmp.OriginalOperationSequence = this.OriginalOperationSequence;
			
			_tmp.LocationId = this.LocationId;
			_tmp.ScheduledStartDate = this.ScheduledStartDate;
			_tmp.ScheduledEndDate = this.ScheduledEndDate;
			_tmp.ActualStartDate = this.ActualStartDate;
			_tmp.ActualEndDate = this.ActualEndDate;
			_tmp.ActualResourceHrs = this.ActualResourceHrs;
			_tmp.PlannedCost = this.PlannedCost;
			_tmp.ActualCost = this.ActualCost;
			_tmp.ModifiedDate = this.ModifiedDate;
			
			#region Source Parent Composite Entities
			if (this.LocationIdSource != null && existingCopies.Contains(this.LocationIdSource))
				_tmp.LocationIdSource = existingCopies[this.LocationIdSource] as Location;
			else
				_tmp.LocationIdSource = MakeCopyOf(this.LocationIdSource, existingCopies) as Location;
			if (this.WorkOrderIdSource != null && existingCopies.Contains(this.WorkOrderIdSource))
				_tmp.WorkOrderIdSource = existingCopies[this.WorkOrderIdSource] as WorkOrder;
			else
				_tmp.WorkOrderIdSource = MakeCopyOf(this.WorkOrderIdSource, existingCopies) as WorkOrder;
			#endregion
		
			#region Child Collections
			#endregion Child Collections
			
			//EntityState
			_tmp.EntityState = this.EntityState;
			
			return _tmp;
		}
		
		#endregion Clone Method
		
		/// <summary>
		///		Indicates state of object
		/// </summary>
		/// <remarks>0=Unchanged, 1=Added, 2=Changed</remarks>
		[BrowsableAttribute(false), XmlIgnoreAttribute()]
		public EntityState	EntityState
		{
			get { return currentEntityState;  }
			set { currentEntityState = value; }
		}
	
	}//End struct

		#endregion
		
				
		
		#region Events trigger
		/// <summary>
		/// Raises the <see cref="ColumnChanging" /> event.
		/// </summary>
		/// <param name="column">The <see cref="WorkOrderRoutingColumn"/> which has raised the event.</param>
		public virtual void OnColumnChanging(WorkOrderRoutingColumn column)
		{
			OnColumnChanging(column, null);
			return;
		}
		
		/// <summary>
		/// Raises the <see cref="ColumnChanged" /> event.
		/// </summary>
		/// <param name="column">The <see cref="WorkOrderRoutingColumn"/> which has raised the event.</param>
		public virtual void OnColumnChanged(WorkOrderRoutingColumn column)
		{
			OnColumnChanged(column, null);
			return;
		} 
		
		
		/// <summary>
		/// Raises the <see cref="ColumnChanging" /> event.
		/// </summary>
		/// <param name="column">The <see cref="WorkOrderRoutingColumn"/> which has raised the event.</param>
		/// <param name="value">The changed value.</param>
		public virtual void OnColumnChanging(WorkOrderRoutingColumn column, object value)
		{
			if(IsEntityTracked && EntityState != EntityState.Added && !EntityManager.TrackChangedEntities)
				EntityManager.StopTracking(entityTrackingKey);
				
			if (!SuppressEntityEvents)
			{
				WorkOrderRoutingEventHandler handler = ColumnChanging;
				if(handler != null)
				{
					handler(this, new WorkOrderRoutingEventArgs(column, value));
				}
			}
		}
		
		/// <summary>
		/// Raises the <see cref="ColumnChanged" /> event.
		/// </summary>
		/// <param name="column">The <see cref="WorkOrderRoutingColumn"/> which has raised the event.</param>
		/// <param name="value">The changed value.</param>
		public virtual void OnColumnChanged(WorkOrderRoutingColumn column, object value)
		{
			if (!SuppressEntityEvents)
			{
				WorkOrderRoutingEventHandler handler = ColumnChanged;
				if(handler != null)
				{
					handler(this, new WorkOrderRoutingEventArgs(column, value));
				}
			
				// warn the parent list that i have changed
				OnEntityChanged();
			}
		} 
		#endregion
			
	} // End Class
	
	
	#region WorkOrderRoutingEventArgs class
	/// <summary>
	/// Provides data for the ColumnChanging and ColumnChanged events.
	/// </summary>
	/// <remarks>
	/// The ColumnChanging and ColumnChanged events occur when a change is made to the value 
	/// of a property of a <see cref="WorkOrderRouting"/> object.
	/// </remarks>
	public class WorkOrderRoutingEventArgs : System.EventArgs
	{
		private WorkOrderRoutingColumn column;
		private object value;
		
		///<summary>
		/// Initalizes a new Instance of the WorkOrderRoutingEventArgs class.
		///</summary>
		public WorkOrderRoutingEventArgs(WorkOrderRoutingColumn column)
		{
			this.column = column;
		}
		
		///<summary>
		/// Initalizes a new Instance of the WorkOrderRoutingEventArgs class.
		///</summary>
		public WorkOrderRoutingEventArgs(WorkOrderRoutingColumn column, object value)
		{
			this.column = column;
			this.value = value;
		}
		
		///<summary>
		/// The WorkOrderRoutingColumn that was modified, which has raised the event.
		///</summary>
		///<value cref="WorkOrderRoutingColumn" />
		public WorkOrderRoutingColumn Column { get { return this.column; } }
		
		/// <summary>
        /// Gets the current value of the column.
        /// </summary>
        /// <value>The current value of the column.</value>
		public object Value{ get { return this.value; } }

	}
	#endregion
	
	///<summary>
	/// Define a delegate for all WorkOrderRouting related events.
	///</summary>
	public delegate void WorkOrderRoutingEventHandler(object sender, WorkOrderRoutingEventArgs e);
	
	#region WorkOrderRoutingComparer
		
	/// <summary>
	///	Strongly Typed IComparer
	/// </summary>
	public class WorkOrderRoutingComparer : System.Collections.Generic.IComparer<WorkOrderRouting>
	{
		WorkOrderRoutingColumn whichComparison;
		
		/// <summary>
        /// Initializes a new instance of the <see cref="T:WorkOrderRoutingComparer"/> class.
        /// </summary>
		public WorkOrderRoutingComparer()
        {            
        }               
        
        /// <summary>
        /// Initializes a new instance of the <see cref="T:WorkOrderRoutingComparer"/> class.
        /// </summary>
        /// <param name="column">The column to sort on.</param>
        public WorkOrderRoutingComparer(WorkOrderRoutingColumn column)
        {
            this.whichComparison = column;
        }

		/// <summary>
        /// Determines whether the specified <see cref="WorkOrderRouting"/> instances are considered equal.
        /// </summary>
        /// <param name="a">The first <see cref="WorkOrderRouting"/> to compare.</param>
        /// <param name="b">The second <c>WorkOrderRouting</c> to compare.</param>
        /// <returns>true if objA is the same instance as objB or if both are null references or if objA.Equals(objB) returns true; otherwise, false.</returns>
        public bool Equals(WorkOrderRouting a, WorkOrderRouting b)
        {
            return this.Compare(a, b) == 0;
        }

		/// <summary>
        /// Gets the hash code of the specified entity.
        /// </summary>
        /// <param name="entity">The entity.</param>
        /// <returns></returns>
        public int GetHashCode(WorkOrderRouting entity)
        {
            return entity.GetHashCode();
        }

        /// <summary>
        /// Performs a case-insensitive comparison of two objects of the same type and returns a value indicating whether one is less than, equal to, or greater than the other.
        /// </summary>
        /// <param name="a">The first object to compare.</param>
        /// <param name="b">The second object to compare.</param>
        /// <returns></returns>
        public int Compare(WorkOrderRouting a, WorkOrderRouting b)
        {
        	EntityPropertyComparer entityPropertyComparer = new EntityPropertyComparer(this.whichComparison.ToString());
        	return entityPropertyComparer.Compare(a, b);
        }

		/// <summary>
        /// Gets or sets the column that will be used for comparison.
        /// </summary>
        /// <value>The comparison column.</value>
        public WorkOrderRoutingColumn WhichComparison
        {
            get { return this.whichComparison; }
            set { this.whichComparison = value; }
        }
	}
	
	#endregion
	
	#region WorkOrderRoutingKey Class

	/// <summary>
	/// Wraps the unique identifier values for the <see cref="WorkOrderRouting"/> object.
	/// </summary>
	[Serializable]
	[CLSCompliant(true)]
	public class WorkOrderRoutingKey : EntityKeyBase
	{
		#region Constructors
		
		/// <summary>
		/// Initializes a new instance of the WorkOrderRoutingKey class.
		/// </summary>
		public WorkOrderRoutingKey()
		{
		}
		
		/// <summary>
		/// Initializes a new instance of the WorkOrderRoutingKey class.
		/// </summary>
		public WorkOrderRoutingKey(WorkOrderRoutingBase entity)
		{
			this.Entity = entity;

			#region Init Properties

			if ( entity != null )
			{
				this.WorkOrderId = entity.WorkOrderId;
				this.ProductId = entity.ProductId;
				this.OperationSequence = entity.OperationSequence;
			}

			#endregion
		}
		
		/// <summary>
		/// Initializes a new instance of the WorkOrderRoutingKey class.
		/// </summary>
		public WorkOrderRoutingKey(System.Int32 _workOrderId, System.Int32 _productId, System.Int16 _operationSequence)
		{
			#region Init Properties

			this.WorkOrderId = _workOrderId;
			this.ProductId = _productId;
			this.OperationSequence = _operationSequence;

			#endregion
		}
		
		#endregion Constructors

		#region Properties
		
		// member variable for the Entity property
		private WorkOrderRoutingBase _entity;
		
		/// <summary>
		/// Gets or sets the Entity property.
		/// </summary>
		public WorkOrderRoutingBase Entity
		{
			get { return _entity; }
			set { _entity = value; }
		}
		
		// member variable for the WorkOrderId property
		private System.Int32 _workOrderId;
		
		/// <summary>
		/// Gets or sets the WorkOrderId property.
		/// </summary>
		public System.Int32 WorkOrderId
		{
			get { return _workOrderId; }
			set
			{
				if ( this.Entity != null )
					this.Entity.WorkOrderId = value;
				
				_workOrderId = value;
			}
		}
		
		// member variable for the ProductId property
		private System.Int32 _productId;
		
		/// <summary>
		/// Gets or sets the ProductId property.
		/// </summary>
		public System.Int32 ProductId
		{
			get { return _productId; }
			set
			{
				if ( this.Entity != null )
					this.Entity.ProductId = value;
				
				_productId = value;
			}
		}
		
		// member variable for the OperationSequence property
		private System.Int16 _operationSequence;
		
		/// <summary>
		/// Gets or sets the OperationSequence property.
		/// </summary>
		public System.Int16 OperationSequence
		{
			get { return _operationSequence; }
			set
			{
				if ( this.Entity != null )
					this.Entity.OperationSequence = value;
				
				_operationSequence = value;
			}
		}
		
		#endregion

		#region Methods
		
		/// <summary>
		/// Reads values from the supplied <see cref="IDictionary"/> object into
		/// properties of the current object.
		/// </summary>
		/// <param name="values">An <see cref="IDictionary"/> instance that contains
		/// the key/value pairs to be used as property values.</param>
		public override void Load(IDictionary values)
		{
			#region Init Properties

			if ( values != null )
			{
				WorkOrderId = ( values["WorkOrderId"] != null ) ? (System.Int32) EntityUtil.ChangeType(values["WorkOrderId"], typeof(System.Int32)) : (int)0;
				ProductId = ( values["ProductId"] != null ) ? (System.Int32) EntityUtil.ChangeType(values["ProductId"], typeof(System.Int32)) : (int)0;
				OperationSequence = ( values["OperationSequence"] != null ) ? (System.Int16) EntityUtil.ChangeType(values["OperationSequence"], typeof(System.Int16)) : (short)0;
			}

			#endregion
		}

		/// <summary>
		/// Creates a new <see cref="IDictionary"/> object and populates it
		/// with the property values of the current object.
		/// </summary>
		/// <returns>A collection of name/value pairs.</returns>
		public override IDictionary ToDictionary()
		{
			IDictionary values = new Hashtable();

			#region Init Dictionary

			values.Add("WorkOrderId", WorkOrderId);
			values.Add("ProductId", ProductId);
			values.Add("OperationSequence", OperationSequence);

			#endregion Init Dictionary

			return values;
		}
		
		///<summary>
		/// Returns a String that represents the current object.
		///</summary>
		public override string ToString()
		{
			return String.Format("WorkOrderId: {0}{3}ProductId: {1}{3}OperationSequence: {2}{3}",
								WorkOrderId,
								ProductId,
								OperationSequence,
								System.Environment.NewLine);
		}

		#endregion Methods
	}
	
	#endregion	

	#region WorkOrderRoutingColumn Enum
	
	/// <summary>
	/// Enumerate the WorkOrderRouting columns.
	/// </summary>
	[Serializable]
	public enum WorkOrderRoutingColumn : int
	{
		/// <summary>
		/// WorkOrderId : Primary key. Foreign key to WorkOrder.WorkOrderID.
		/// </summary>
		[EnumTextValue("WorkOrderID")]
		[ColumnEnum("WorkOrderID", typeof(System.Int32), System.Data.DbType.Int32, true, false, false)]
		WorkOrderId = 1,
		/// <summary>
		/// ProductId : Primary key. Foreign key to Product.ProductID.
		/// </summary>
		[EnumTextValue("ProductID")]
		[ColumnEnum("ProductID", typeof(System.Int32), System.Data.DbType.Int32, true, false, false)]
		ProductId = 2,
		/// <summary>
		/// OperationSequence : Primary key. Indicates the manufacturing process sequence.
		/// </summary>
		[EnumTextValue("OperationSequence")]
		[ColumnEnum("OperationSequence", typeof(System.Int16), System.Data.DbType.Int16, true, false, false)]
		OperationSequence = 3,
		/// <summary>
		/// LocationId : Manufacturing location where the part is processed. Foreign key to Location.LocationID.
		/// </summary>
		[EnumTextValue("LocationID")]
		[ColumnEnum("LocationID", typeof(System.Int16), System.Data.DbType.Int16, false, false, false)]
		LocationId = 4,
		/// <summary>
		/// ScheduledStartDate : Planned manufacturing start date.
		/// </summary>
		[EnumTextValue("ScheduledStartDate")]
		[ColumnEnum("ScheduledStartDate", typeof(System.DateTime), System.Data.DbType.DateTime, false, false, false)]
		ScheduledStartDate = 5,
		/// <summary>
		/// ScheduledEndDate : Planned manufacturing end date.
		/// </summary>
		[EnumTextValue("ScheduledEndDate")]
		[ColumnEnum("ScheduledEndDate", typeof(System.DateTime), System.Data.DbType.DateTime, false, false, false)]
		ScheduledEndDate = 6,
		/// <summary>
		/// ActualStartDate : Actual start date.
		/// </summary>
		[EnumTextValue("ActualStartDate")]
		[ColumnEnum("ActualStartDate", typeof(System.DateTime), System.Data.DbType.DateTime, false, false, true)]
		ActualStartDate = 7,
		/// <summary>
		/// ActualEndDate : Actual end date.
		/// </summary>
		[EnumTextValue("ActualEndDate")]
		[ColumnEnum("ActualEndDate", typeof(System.DateTime), System.Data.DbType.DateTime, false, false, true)]
		ActualEndDate = 8,
		/// <summary>
		/// ActualResourceHrs : Number of manufacturing hours used.
		/// </summary>
		[EnumTextValue("ActualResourceHrs")]
		[ColumnEnum("ActualResourceHrs", typeof(System.Decimal), System.Data.DbType.Decimal, false, false, true)]
		ActualResourceHrs = 9,
		/// <summary>
		/// PlannedCost : Estimated manufacturing cost.
		/// </summary>
		[EnumTextValue("PlannedCost")]
		[ColumnEnum("PlannedCost", typeof(System.Decimal), System.Data.DbType.Currency, false, false, false)]
		PlannedCost = 10,
		/// <summary>
		/// ActualCost : Actual manufacturing cost.
		/// </summary>
		[EnumTextValue("ActualCost")]
		[ColumnEnum("ActualCost", typeof(System.Decimal), System.Data.DbType.Currency, false, false, true)]
		ActualCost = 11,
		/// <summary>
		/// ModifiedDate : Date and time the record was last updated.
		/// </summary>
		[EnumTextValue("ModifiedDate")]
		[ColumnEnum("ModifiedDate", typeof(System.DateTime), System.Data.DbType.DateTime, false, false, false)]
		ModifiedDate = 12
	}//End enum

	#endregion WorkOrderRoutingColumn Enum

} // end namespace
