#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="pubs")]
public partial class DataClassesDataContext : System.Data.Linq.DataContext
{
	
	private static System.Data.Linq.Mapping.MappingSource mappingSource = new AttributeMappingSource();
	
  #region Extensibility Method Definitions
  partial void OnCreated();
  partial void Inserttitle(title instance);
  partial void Updatetitle(title instance);
  partial void Deletetitle(title instance);
  partial void Insertpublisher(publisher instance);
  partial void Updatepublisher(publisher instance);
  partial void Deletepublisher(publisher instance);
  #endregion
	
	public DataClassesDataContext() : 
			base(global::System.Configuration.ConfigurationManager.ConnectionStrings["pubsConnectionString"].ConnectionString, mappingSource)
	{
		OnCreated();
	}
	
	public DataClassesDataContext(string connection) : 
			base(connection, mappingSource)
	{
		OnCreated();
	}
	
	public DataClassesDataContext(System.Data.IDbConnection connection) : 
			base(connection, mappingSource)
	{
		OnCreated();
	}
	
	public DataClassesDataContext(string connection, System.Data.Linq.Mapping.MappingSource mappingSource) : 
			base(connection, mappingSource)
	{
		OnCreated();
	}
	
	public DataClassesDataContext(System.Data.IDbConnection connection, System.Data.Linq.Mapping.MappingSource mappingSource) : 
			base(connection, mappingSource)
	{
		OnCreated();
	}
	
	public System.Data.Linq.Table<title> titles
	{
		get
		{
			return this.GetTable<title>();
		}
	}
	
	public System.Data.Linq.Table<publisher> publishers
	{
		get
		{
			return this.GetTable<publisher>();
		}
	}
}

[Table(Name="dbo.titles")]
public partial class title : INotifyPropertyChanging, INotifyPropertyChanged
{
	
	private static PropertyChangingEventArgs emptyChangingEventArgs = new PropertyChangingEventArgs(String.Empty);
	
	private string _title_id;
	
	private string _title1;
	
	private string _type;
	
	private string _pub_id;
	
	private System.Nullable<decimal> _price;
	
	private System.Nullable<decimal> _advance;
	
	private System.Nullable<int> _royalty;
	
	private System.Nullable<int> _ytd_sales;
	
	private string _notes;
	
	private System.DateTime _pubdate;
	
	private EntityRef<publisher> _publisher;
	
    #region Extensibility Method Definitions
    partial void OnLoaded();
    partial void OnValidate(System.Data.Linq.ChangeAction action);
    partial void OnCreated();
    partial void Ontitle_idChanging(string value);
    partial void Ontitle_idChanged();
    partial void Ontitle1Changing(string value);
    partial void Ontitle1Changed();
    partial void OntypeChanging(string value);
    partial void OntypeChanged();
    partial void Onpub_idChanging(string value);
    partial void Onpub_idChanged();
    partial void OnpriceChanging(System.Nullable<decimal> value);
    partial void OnpriceChanged();
    partial void OnadvanceChanging(System.Nullable<decimal> value);
    partial void OnadvanceChanged();
    partial void OnroyaltyChanging(System.Nullable<int> value);
    partial void OnroyaltyChanged();
    partial void Onytd_salesChanging(System.Nullable<int> value);
    partial void Onytd_salesChanged();
    partial void OnnotesChanging(string value);
    partial void OnnotesChanged();
    partial void OnpubdateChanging(System.DateTime value);
    partial void OnpubdateChanged();
    #endregion
	
	public title()
	{
		this._publisher = default(EntityRef<publisher>);
		OnCreated();
	}
	
	[Column(Storage="_title_id", DbType="VarChar(6) NOT NULL", CanBeNull=false, IsPrimaryKey=true)]
	public string title_id
	{
		get
		{
			return this._title_id;
		}
		set
		{
			if ((this._title_id != value))
			{
				this.Ontitle_idChanging(value);
				this.SendPropertyChanging();
				this._title_id = value;
				this.SendPropertyChanged("title_id");
				this.Ontitle_idChanged();
			}
		}
	}
	
	[Column(Name="title", Storage="_title1", DbType="VarChar(80) NOT NULL", CanBeNull=false)]
	public string title1
	{
		get
		{
			return this._title1;
		}
		set
		{
			if ((this._title1 != value))
			{
				this.Ontitle1Changing(value);
				this.SendPropertyChanging();
				this._title1 = value;
				this.SendPropertyChanged("title1");
				this.Ontitle1Changed();
			}
		}
	}
	
	[Column(Storage="_type", DbType="Char(12) NOT NULL", CanBeNull=false)]
	public string type
	{
		get
		{
			return this._type;
		}
		set
		{
			if ((this._type != value))
			{
				this.OntypeChanging(value);
				this.SendPropertyChanging();
				this._type = value;
				this.SendPropertyChanged("type");
				this.OntypeChanged();
			}
		}
	}
	
	[Column(Storage="_pub_id", DbType="Char(4)")]
	public string pub_id
	{
		get
		{
			return this._pub_id;
		}
		set
		{
			if ((this._pub_id != value))
			{
				if (this._publisher.HasLoadedOrAssignedValue)
				{
					throw new System.Data.Linq.ForeignKeyReferenceAlreadyHasValueException();
				}
				this.Onpub_idChanging(value);
				this.SendPropertyChanging();
				this._pub_id = value;
				this.SendPropertyChanged("pub_id");
				this.Onpub_idChanged();
			}
		}
	}
	
	[Column(Storage="_price", DbType="Money")]
	public System.Nullable<decimal> price
	{
		get
		{
			return this._price;
		}
		set
		{
			if ((this._price != value))
			{
				this.OnpriceChanging(value);
				this.SendPropertyChanging();
				this._price = value;
				this.SendPropertyChanged("price");
				this.OnpriceChanged();
			}
		}
	}
	
	[Column(Storage="_advance", DbType="Money")]
	public System.Nullable<decimal> advance
	{
		get
		{
			return this._advance;
		}
		set
		{
			if ((this._advance != value))
			{
				this.OnadvanceChanging(value);
				this.SendPropertyChanging();
				this._advance = value;
				this.SendPropertyChanged("advance");
				this.OnadvanceChanged();
			}
		}
	}
	
	[Column(Storage="_royalty", DbType="Int")]
	public System.Nullable<int> royalty
	{
		get
		{
			return this._royalty;
		}
		set
		{
			if ((this._royalty != value))
			{
				this.OnroyaltyChanging(value);
				this.SendPropertyChanging();
				this._royalty = value;
				this.SendPropertyChanged("royalty");
				this.OnroyaltyChanged();
			}
		}
	}
	
	[Column(Storage="_ytd_sales", DbType="Int")]
	public System.Nullable<int> ytd_sales
	{
		get
		{
			return this._ytd_sales;
		}
		set
		{
			if ((this._ytd_sales != value))
			{
				this.Onytd_salesChanging(value);
				this.SendPropertyChanging();
				this._ytd_sales = value;
				this.SendPropertyChanged("ytd_sales");
				this.Onytd_salesChanged();
			}
		}
	}
	
	[Column(Storage="_notes", DbType="VarChar(200)")]
	public string notes
	{
		get
		{
			return this._notes;
		}
		set
		{
			if ((this._notes != value))
			{
				this.OnnotesChanging(value);
				this.SendPropertyChanging();
				this._notes = value;
				this.SendPropertyChanged("notes");
				this.OnnotesChanged();
			}
		}
	}
	
	[Column(Storage="_pubdate", DbType="DateTime NOT NULL")]
	public System.DateTime pubdate
	{
		get
		{
			return this._pubdate;
		}
		set
		{
			if ((this._pubdate != value))
			{
				this.OnpubdateChanging(value);
				this.SendPropertyChanging();
				this._pubdate = value;
				this.SendPropertyChanged("pubdate");
				this.OnpubdateChanged();
			}
		}
	}
	
	[Association(Name="publisher_title", Storage="_publisher", ThisKey="pub_id", IsForeignKey=true)]
	public publisher publisher
	{
		get
		{
			return this._publisher.Entity;
		}
		set
		{
			publisher previousValue = this._publisher.Entity;
			if (((previousValue != value) 
						|| (this._publisher.HasLoadedOrAssignedValue == false)))
			{
				this.SendPropertyChanging();
				if ((previousValue != null))
				{
					this._publisher.Entity = null;
					previousValue.titles.Remove(this);
				}
				this._publisher.Entity = value;
				if ((value != null))
				{
					value.titles.Add(this);
					this._pub_id = value.pub_id;
				}
				else
				{
					this._pub_id = default(string);
				}
				this.SendPropertyChanged("publisher");
			}
		}
	}
	
	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.publishers")]
public partial class publisher : INotifyPropertyChanging, INotifyPropertyChanged
{
	
	private static PropertyChangingEventArgs emptyChangingEventArgs = new PropertyChangingEventArgs(String.Empty);
	
	private string _pub_id;
	
	private string _pub_name;
	
	private string _city;
	
	private string _state;
	
	private string _country;
	
	private EntitySet<title> _titles;
	
    #region Extensibility Method Definitions
    partial void OnLoaded();
    partial void OnValidate(System.Data.Linq.ChangeAction action);
    partial void OnCreated();
    partial void Onpub_idChanging(string value);
    partial void Onpub_idChanged();
    partial void Onpub_nameChanging(string value);
    partial void Onpub_nameChanged();
    partial void OncityChanging(string value);
    partial void OncityChanged();
    partial void OnstateChanging(string value);
    partial void OnstateChanged();
    partial void OncountryChanging(string value);
    partial void OncountryChanged();
    #endregion
	
	public publisher()
	{
		this._titles = new EntitySet<title>(new Action<title>(this.attach_titles), new Action<title>(this.detach_titles));
		OnCreated();
	}
	
	[Column(Storage="_pub_id", DbType="Char(4) NOT NULL", CanBeNull=false, IsPrimaryKey=true)]
	public string pub_id
	{
		get
		{
			return this._pub_id;
		}
		set
		{
			if ((this._pub_id != value))
			{
				this.Onpub_idChanging(value);
				this.SendPropertyChanging();
				this._pub_id = value;
				this.SendPropertyChanged("pub_id");
				this.Onpub_idChanged();
			}
		}
	}
	
	[Column(Storage="_pub_name", DbType="VarChar(40)")]
	public string pub_name
	{
		get
		{
			return this._pub_name;
		}
		set
		{
			if ((this._pub_name != value))
			{
				this.Onpub_nameChanging(value);
				this.SendPropertyChanging();
				this._pub_name = value;
				this.SendPropertyChanged("pub_name");
				this.Onpub_nameChanged();
			}
		}
	}
	
	[Column(Storage="_city", DbType="VarChar(20)")]
	public string city
	{
		get
		{
			return this._city;
		}
		set
		{
			if ((this._city != value))
			{
				this.OncityChanging(value);
				this.SendPropertyChanging();
				this._city = value;
				this.SendPropertyChanged("city");
				this.OncityChanged();
			}
		}
	}
	
	[Column(Storage="_state", DbType="Char(2)")]
	public string state
	{
		get
		{
			return this._state;
		}
		set
		{
			if ((this._state != value))
			{
				this.OnstateChanging(value);
				this.SendPropertyChanging();
				this._state = value;
				this.SendPropertyChanged("state");
				this.OnstateChanged();
			}
		}
	}
	
	[Column(Storage="_country", DbType="VarChar(30)")]
	public string country
	{
		get
		{
			return this._country;
		}
		set
		{
			if ((this._country != value))
			{
				this.OncountryChanging(value);
				this.SendPropertyChanging();
				this._country = value;
				this.SendPropertyChanged("country");
				this.OncountryChanged();
			}
		}
	}
	
	[Association(Name="publisher_title", Storage="_titles", OtherKey="pub_id")]
	public EntitySet<title> titles
	{
		get
		{
			return this._titles;
		}
		set
		{
			this._titles.Assign(value);
		}
	}
	
	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));
		}
	}
	
	private void attach_titles(title entity)
	{
		this.SendPropertyChanging();
		entity.publisher = this;
	}
	
	private void detach_titles(title entity)
	{
		this.SendPropertyChanging();
		entity.publisher = null;
	}
}
#pragma warning restore 1591
