﻿#pragma warning disable 0649
//------------------------------------------------------------------------------
// <auto-generated>This code was generated by LLBLGen Pro v4.1.</auto-generated>
//------------------------------------------------------------------------------
using System;
using System.Data.Linq;
using System.Data.Linq.Mapping;
using System.ComponentModel;

namespace L2S.Bencher.EntityClasses
{
	/// <summary>Class which represents the entity 'ProductReview', mapped on table 'AdventureWorks.Production.ProductReview'.</summary>
	[Table(Name="[Production].[ProductReview]")]
	public partial class ProductReview : INotifyPropertyChanging, INotifyPropertyChanged
	{
		#region Events
		/// <summary>Event which is raised when a property value is changing.</summary>
		public event PropertyChangingEventHandler PropertyChanging;
		/// <summary>Event which is raised when a property value changes.</summary>
		public event PropertyChangedEventHandler PropertyChanged;
		#endregion
		
		#region Class Member Declarations
		private System.String	_comments;
		private System.String	_emailAddress;
		private System.DateTime	_modifiedDate;
		private System.Int32	_productId;
		private System.Int32	_productReviewId;
		private System.Int32	_rating;
		private System.DateTime	_reviewDate;
		private System.String	_reviewerName;
		private EntityRef <Product> _product;
		#endregion
		
		#region Extensibility Method Definitions
		partial void OnLoaded();
		partial void OnValidate(System.Data.Linq.ChangeAction action);
		partial void OnCreated();
		partial void OnCommentsChanging(System.String value);
		partial void OnCommentsChanged();
		partial void OnEmailAddressChanging(System.String value);
		partial void OnEmailAddressChanged();
		partial void OnModifiedDateChanging(System.DateTime value);
		partial void OnModifiedDateChanged();
		partial void OnProductIdChanging(System.Int32 value);
		partial void OnProductIdChanged();
		partial void OnProductReviewIdChanging(System.Int32 value);
		partial void OnProductReviewIdChanged();
		partial void OnRatingChanging(System.Int32 value);
		partial void OnRatingChanged();
		partial void OnReviewDateChanging(System.DateTime value);
		partial void OnReviewDateChanged();
		partial void OnReviewerNameChanging(System.String value);
		partial void OnReviewerNameChanged();
		#endregion
		
		/// <summary>Initializes a new instance of the <see cref="ProductReview"/> class.</summary>
		public ProductReview()
		{
			_product = default(EntityRef<Product>);
			OnCreated();
		}

		/// <summary>Raises the PropertyChanging event</summary>
		/// <param name="propertyName">name of the property which is changing</param>
		protected virtual void SendPropertyChanging(string propertyName)
		{
			if((this.PropertyChanging != null))
			{
				this.PropertyChanging(this, new PropertyChangingEventArgs(propertyName));
			}
		}
		
		/// <summary>Raises the PropertyChanged event for the property specified</summary>
		/// <param name="propertyName">name of the property which was changed</param>
		protected virtual void SendPropertyChanged(string propertyName)
		{
			if((this.PropertyChanged != null))
			{
				this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
			}
		}
		

		#region Class Property Declarations
		/// <summary>Gets or sets the Comments field. Mapped on target field 'Comments'. </summary>
		[Column(Name="Comments", Storage="_comments", DbType="nvarchar(3850) NULL")]
		public System.String Comments
		{
			get	{ return _comments; }
			set
			{
				if((_comments != value))
				{
					OnCommentsChanging(value);
					SendPropertyChanging("Comments");
					_comments = value;
					SendPropertyChanged("Comments");
					OnCommentsChanged();
				}
			}
		}

		/// <summary>Gets or sets the EmailAddress field. Mapped on target field 'EmailAddress'. </summary>
		[Column(Name="EmailAddress", Storage="_emailAddress", CanBeNull=false, DbType="nvarchar(50) NOT NULL")]
		public System.String EmailAddress
		{
			get	{ return _emailAddress; }
			set
			{
				if((_emailAddress != value))
				{
					OnEmailAddressChanging(value);
					SendPropertyChanging("EmailAddress");
					_emailAddress = value;
					SendPropertyChanged("EmailAddress");
					OnEmailAddressChanged();
				}
			}
		}

		/// <summary>Gets or sets the ModifiedDate field. Mapped on target field 'ModifiedDate'. </summary>
		[Column(Name="ModifiedDate", Storage="_modifiedDate", CanBeNull=false, DbType="datetime NOT NULL")]
		public System.DateTime ModifiedDate
		{
			get	{ return _modifiedDate; }
			set
			{
				if((_modifiedDate != value))
				{
					OnModifiedDateChanging(value);
					SendPropertyChanging("ModifiedDate");
					_modifiedDate = value;
					SendPropertyChanged("ModifiedDate");
					OnModifiedDateChanged();
				}
			}
		}

		/// <summary>Gets or sets the ProductId field. Mapped on target field 'ProductID'. </summary>
		[Column(Name="ProductID", Storage="_productId", CanBeNull=false, DbType="int NOT NULL")]
		public System.Int32 ProductId
		{
			get	{ return _productId; }
			set
			{
				if((_productId != value))
				{
					if(_product.HasLoadedOrAssignedValue)
					{
						throw new System.Data.Linq.ForeignKeyReferenceAlreadyHasValueException();
					}
					OnProductIdChanging(value);
					SendPropertyChanging("ProductId");
					_productId = value;
					SendPropertyChanged("ProductId");
					OnProductIdChanged();
				}
			}
		}

		/// <summary>Gets or sets the ProductReviewId field. Mapped on target field 'ProductReviewID'. </summary>
		[Column(Name="ProductReviewID", Storage="_productReviewId", AutoSync=AutoSync.OnInsert, CanBeNull=false, DbType="int NOT NULL IDENTITY", IsPrimaryKey=true, IsDbGenerated=true, UpdateCheck=UpdateCheck.Never)]
		public System.Int32 ProductReviewId
		{
			get	{ return _productReviewId; }
			set
			{
				if((_productReviewId != value))
				{
					OnProductReviewIdChanging(value);
					SendPropertyChanging("ProductReviewId");
					_productReviewId = value;
					SendPropertyChanged("ProductReviewId");
					OnProductReviewIdChanged();
				}
			}
		}

		/// <summary>Gets or sets the Rating field. Mapped on target field 'Rating'. </summary>
		[Column(Name="Rating", Storage="_rating", CanBeNull=false, DbType="int NOT NULL")]
		public System.Int32 Rating
		{
			get	{ return _rating; }
			set
			{
				if((_rating != value))
				{
					OnRatingChanging(value);
					SendPropertyChanging("Rating");
					_rating = value;
					SendPropertyChanged("Rating");
					OnRatingChanged();
				}
			}
		}

		/// <summary>Gets or sets the ReviewDate field. Mapped on target field 'ReviewDate'. </summary>
		[Column(Name="ReviewDate", Storage="_reviewDate", CanBeNull=false, DbType="datetime NOT NULL")]
		public System.DateTime ReviewDate
		{
			get	{ return _reviewDate; }
			set
			{
				if((_reviewDate != value))
				{
					OnReviewDateChanging(value);
					SendPropertyChanging("ReviewDate");
					_reviewDate = value;
					SendPropertyChanged("ReviewDate");
					OnReviewDateChanged();
				}
			}
		}

		/// <summary>Gets or sets the ReviewerName field. Mapped on target field 'ReviewerName'. </summary>
		[Column(Name="ReviewerName", Storage="_reviewerName", CanBeNull=false, DbType="nvarchar(50) NOT NULL")]
		public System.String ReviewerName
		{
			get	{ return _reviewerName; }
			set
			{
				if((_reviewerName != value))
				{
					OnReviewerNameChanging(value);
					SendPropertyChanging("ReviewerName");
					_reviewerName = value;
					SendPropertyChanged("ReviewerName");
					OnReviewerNameChanged();
				}
			}
		}

		/// <summary>Represents the navigator which is mapped onto the association 'ProductReview.Product - Product.ProductReviews (m:1)'</summary>
		[Association(Name="ProductReview_Product179037abdb49461bbd96ab67c4e9e6cf", Storage="_product", ThisKey="ProductId", IsForeignKey=true)] 
		public Product Product
		{
			get { return _product.Entity; }
			set
			{
				Product previousValue = _product.Entity;
				if((previousValue != value) || (_product.HasLoadedOrAssignedValue == false))
				{
					this.SendPropertyChanging("Product");
					if(previousValue != null)
					{
						_product.Entity = null;
						previousValue.ProductReviews.Remove(this);
					}
					_product.Entity = value;
					if(value == null)
					{
						_productId = default(System.Int32);
					}
					else
					{
						value.ProductReviews.Add(this);
						_productId = value.ProductId;
					}
					this.SendPropertyChanged("Product");
				}
			}
		}
		
		#endregion
	}
}
#pragma warning restore 0649