#pragma warning disable 1591
//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a tool.
//     Runtime Version:2.0.50727.3031
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.Linq;
using System.Data.Linq.Mapping;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;



[System.Data.Linq.Mapping.DatabaseAttribute(Name="Northwind")]
public partial class NorthwindDataContext : System.Data.Linq.DataContext
{
	
	private static System.Data.Linq.Mapping.MappingSource mappingSource = new AttributeMappingSource();
	
  #region Extensibility Method Definitions
  partial void OnCreated();
  partial void InsertCategory(Category instance);
  partial void UpdateCategory(Category instance);
  partial void DeleteCategory(Category instance);
  partial void InsertProduct(Product instance);
  partial void UpdateProduct(Product instance);
  partial void DeleteProduct(Product instance);
  #endregion
	
	public NorthwindDataContext() : 
			base(global::System.Configuration.ConfigurationManager.ConnectionStrings["NorthwindConnectionString"].ConnectionString, mappingSource)
	{
		OnCreated();
	}
	
	public NorthwindDataContext(string connection) : 
			base(connection, mappingSource)
	{
		OnCreated();
	}
	
	public NorthwindDataContext(System.Data.IDbConnection connection) : 
			base(connection, mappingSource)
	{
		OnCreated();
	}
	
	public NorthwindDataContext(string connection, System.Data.Linq.Mapping.MappingSource mappingSource) : 
			base(connection, mappingSource)
	{
		OnCreated();
	}
	
	public NorthwindDataContext(System.Data.IDbConnection connection, System.Data.Linq.Mapping.MappingSource mappingSource) : 
			base(connection, mappingSource)
	{
		OnCreated();
	}
	
	public System.Data.Linq.Table<Category> Categories
	{
		get
		{
			return this.GetTable<Category>();
		}
	}
	
	public System.Data.Linq.Table<Product> Products
	{
		get
		{
			return this.GetTable<Product>();
		}
	}
}

[Table(Name="dbo.Categories")]
public partial class Category : INotifyPropertyChanging, INotifyPropertyChanged
{
	
	private static PropertyChangingEventArgs emptyChangingEventArgs = new PropertyChangingEventArgs(String.Empty);
	
	private int _CategoryID;
	
	private string _CategoryName;
	
	private string _Description;
	
	private System.Data.Linq.Binary _Picture;
	
    #region Extensibility Method Definitions
    partial void OnLoaded();
    partial void OnValidate(System.Data.Linq.ChangeAction action);
    partial void OnCreated();
    partial void OnCategoryIDChanging(int value);
    partial void OnCategoryIDChanged();
    partial void OnCategoryNameChanging(string value);
    partial void OnCategoryNameChanged();
    partial void OnDescriptionChanging(string value);
    partial void OnDescriptionChanged();
    partial void OnPictureChanging(System.Data.Linq.Binary value);
    partial void OnPictureChanged();
    #endregion
	
	public Category()
	{
		OnCreated();
	}
	
	[Column(Storage="_CategoryID", AutoSync=AutoSync.OnInsert, DbType="Int NOT NULL IDENTITY", IsPrimaryKey=true, IsDbGenerated=true)]
	public int CategoryID
	{
		get
		{
			return this._CategoryID;
		}
		set
		{
			if ((this._CategoryID != value))
			{
				this.OnCategoryIDChanging(value);
				this.SendPropertyChanging();
				this._CategoryID = value;
				this.SendPropertyChanged("CategoryID");
				this.OnCategoryIDChanged();
			}
		}
	}
	
	[Column(Storage="_CategoryName", DbType="NVarChar(15) NOT NULL", CanBeNull=false)]
	public string CategoryName
	{
		get
		{
			return this._CategoryName;
		}
		set
		{
			if ((this._CategoryName != value))
			{
				this.OnCategoryNameChanging(value);
				this.SendPropertyChanging();
				this._CategoryName = value;
				this.SendPropertyChanged("CategoryName");
				this.OnCategoryNameChanged();
			}
		}
	}
	
	[Column(Storage="_Description", DbType="NText", UpdateCheck=UpdateCheck.Never)]
	public string Description
	{
		get
		{
			return this._Description;
		}
		set
		{
			if ((this._Description != value))
			{
				this.OnDescriptionChanging(value);
				this.SendPropertyChanging();
				this._Description = value;
				this.SendPropertyChanged("Description");
				this.OnDescriptionChanged();
			}
		}
	}
	
	[Column(Storage="_Picture", DbType="Image", UpdateCheck=UpdateCheck.Never)]
	public System.Data.Linq.Binary Picture
	{
		get
		{
			return this._Picture;
		}
		set
		{
			if ((this._Picture != value))
			{
				this.OnPictureChanging(value);
				this.SendPropertyChanging();
				this._Picture = value;
				this.SendPropertyChanged("Picture");
				this.OnPictureChanged();
			}
		}
	}
	
	public event PropertyChangingEventHandler PropertyChanging;
	
	public event PropertyChangedEventHandler PropertyChanged;
	
	protected virtual void SendPropertyChanging()
	{
		if ((this.PropertyChanging != null))
		{
			this.PropertyChanging(this, emptyChangingEventArgs);
		}
	}
	
	protected virtual void SendPropertyChanged(String propertyName)
	{
		if ((this.PropertyChanged != null))
		{
			this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
		}
	}
}

[Table(Name="dbo.Products")]
public partial class Product : INotifyPropertyChanging, INotifyPropertyChanged
{
	
	private static PropertyChangingEventArgs emptyChangingEventArgs = new PropertyChangingEventArgs(String.Empty);
	
	private int _ProductID;
	
	private string _ProductName;
	
	private System.Nullable<int> _SupplierID;
	
	private System.Nullable<int> _CategoryID;
	
	private string _QuantityPerUnit;
	
	private System.Nullable<decimal> _UnitPrice;
	
	private System.Nullable<short> _UnitsInStock;
	
	private System.Nullable<short> _UnitsOnOrder;
	
	private System.Nullable<short> _ReorderLevel;
	
	private bool _Discontinued;
	
	private EntityRef<Category> _Category;
	
    #region Extensibility Method Definitions
    partial void OnLoaded();
    partial void OnValidate(System.Data.Linq.ChangeAction action);
    partial void OnCreated();
    partial void OnProductIDChanging(int value);
    partial void OnProductIDChanged();
    partial void OnProductNameChanging(string value);
    partial void OnProductNameChanged();
    partial void OnSupplierIDChanging(System.Nullable<int> value);
    partial void OnSupplierIDChanged();
    partial void OnCategoryIDChanging(System.Nullable<int> value);
    partial void OnCategoryIDChanged();
    partial void OnQuantityPerUnitChanging(string value);
    partial void OnQuantityPerUnitChanged();
    partial void OnUnitPriceChanging(System.Nullable<decimal> value);
    partial void OnUnitPriceChanged();
    partial void OnUnitsInStockChanging(System.Nullable<short> value);
    partial void OnUnitsInStockChanged();
    partial void OnUnitsOnOrderChanging(System.Nullable<short> value);
    partial void OnUnitsOnOrderChanged();
    partial void OnReorderLevelChanging(System.Nullable<short> value);
    partial void OnReorderLevelChanged();
    partial void OnDiscontinuedChanging(bool value);
    partial void OnDiscontinuedChanged();
    #endregion
	
	public Product()
	{
		this._Category = default(EntityRef<Category>);
		OnCreated();
	}
	
	[Column(Storage="_ProductID", AutoSync=AutoSync.OnInsert, DbType="Int NOT NULL IDENTITY", IsPrimaryKey=true, IsDbGenerated=true)]
	public int ProductID
	{
		get
		{
			return this._ProductID;
		}
		set
		{
			if ((this._ProductID != value))
			{
				this.OnProductIDChanging(value);
				this.SendPropertyChanging();
				this._ProductID = value;
				this.SendPropertyChanged("ProductID");
				this.OnProductIDChanged();
			}
		}
	}
	
	[Column(Storage="_ProductName", DbType="NVarChar(40) NOT NULL", CanBeNull=false)]
	public string ProductName
	{
		get
		{
			return this._ProductName;
		}
		set
		{
			if ((this._ProductName != value))
			{
				this.OnProductNameChanging(value);
				this.SendPropertyChanging();
				this._ProductName = value;
				this.SendPropertyChanged("ProductName");
				this.OnProductNameChanged();
			}
		}
	}
	
	[Column(Storage="_SupplierID", DbType="Int")]
	public System.Nullable<int> SupplierID
	{
		get
		{
			return this._SupplierID;
		}
		set
		{
			if ((this._SupplierID != value))
			{
				this.OnSupplierIDChanging(value);
				this.SendPropertyChanging();
				this._SupplierID = value;
				this.SendPropertyChanged("SupplierID");
				this.OnSupplierIDChanged();
			}
		}
	}
	
	[Column(Storage="_CategoryID", DbType="Int")]
	public System.Nullable<int> CategoryID
	{
		get
		{
			return this._CategoryID;
		}
		set
		{
			if ((this._CategoryID != value))
			{
				if (this._Category.HasLoadedOrAssignedValue)
				{
					throw new System.Data.Linq.ForeignKeyReferenceAlreadyHasValueException();
				}
				this.OnCategoryIDChanging(value);
				this.SendPropertyChanging();
				this._CategoryID = value;
				this.SendPropertyChanged("CategoryID");
				this.OnCategoryIDChanged();
			}
		}
	}
	
	[Column(Storage="_QuantityPerUnit", DbType="NVarChar(20)")]
	public string QuantityPerUnit
	{
		get
		{
			return this._QuantityPerUnit;
		}
		set
		{
			if ((this._QuantityPerUnit != value))
			{
				this.OnQuantityPerUnitChanging(value);
				this.SendPropertyChanging();
				this._QuantityPerUnit = value;
				this.SendPropertyChanged("QuantityPerUnit");
				this.OnQuantityPerUnitChanged();
			}
		}
	}
	
	[Column(Storage="_UnitPrice", DbType="Decimal(5,2)")]
	public System.Nullable<decimal> UnitPrice
	{
		get
		{
			return this._UnitPrice;
		}
		set
		{
			if ((this._UnitPrice != value))
			{
				this.OnUnitPriceChanging(value);
				this.SendPropertyChanging();
				this._UnitPrice = value;
				this.SendPropertyChanged("UnitPrice");
				this.OnUnitPriceChanged();
			}
		}
	}
	
	[Column(Storage="_UnitsInStock", DbType="SmallInt")]
	public System.Nullable<short> UnitsInStock
	{
		get
		{
			return this._UnitsInStock;
		}
		set
		{
			if ((this._UnitsInStock != value))
			{
				this.OnUnitsInStockChanging(value);
				this.SendPropertyChanging();
				this._UnitsInStock = value;
				this.SendPropertyChanged("UnitsInStock");
				this.OnUnitsInStockChanged();
			}
		}
	}
	
	[Column(Storage="_UnitsOnOrder", DbType="SmallInt")]
	public System.Nullable<short> UnitsOnOrder
	{
		get
		{
			return this._UnitsOnOrder;
		}
		set
		{
			if ((this._UnitsOnOrder != value))
			{
				this.OnUnitsOnOrderChanging(value);
				this.SendPropertyChanging();
				this._UnitsOnOrder = value;
				this.SendPropertyChanged("UnitsOnOrder");
				this.OnUnitsOnOrderChanged();
			}
		}
	}
	
	[Column(Storage="_ReorderLevel", DbType="SmallInt")]
	public System.Nullable<short> ReorderLevel
	{
		get
		{
			return this._ReorderLevel;
		}
		set
		{
			if ((this._ReorderLevel != value))
			{
				this.OnReorderLevelChanging(value);
				this.SendPropertyChanging();
				this._ReorderLevel = value;
				this.SendPropertyChanged("ReorderLevel");
				this.OnReorderLevelChanged();
			}
		}
	}
	
	[Column(Storage="_Discontinued", DbType="Bit NOT NULL")]
	public bool Discontinued
	{
		get
		{
			return this._Discontinued;
		}
		set
		{
			if ((this._Discontinued != value))
			{
				this.OnDiscontinuedChanging(value);
				this.SendPropertyChanging();
				this._Discontinued = value;
				this.SendPropertyChanged("Discontinued");
				this.OnDiscontinuedChanged();
			}
		}
	}
	
	[Association(Name="Category_Product", Storage="_Category", ThisKey="CategoryID", IsForeignKey=true)]
	public Category Category
	{
		get
		{
			return this._Category.Entity;
		}
		set
		{
			if ((this._Category.Entity != value))
			{
				this.SendPropertyChanging();
				this._Category.Entity = value;
				this.SendPropertyChanged("Category");
			}
		}
	}
	
	public event PropertyChangingEventHandler PropertyChanging;
	
	public event PropertyChangedEventHandler PropertyChanged;
	
	protected virtual void SendPropertyChanging()
	{
		if ((this.PropertyChanging != null))
		{
			this.PropertyChanging(this, emptyChangingEventArgs);
		}
	}
	
	protected virtual void SendPropertyChanged(String propertyName)
	{
		if ((this.PropertyChanged != null))
		{
			this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
		}
	}
}
#pragma warning restore 1591
