#pragma warning disable 1591
//------------------------------------------------------------------------------
// <auto-generated>
//     此代码由工具生成。
//     运行时版本:2.0.50727.5456
//
//     对此文件的更改可能会导致不正确的行为，并且如果
//     重新生成代码，这些更改将会丢失。
// </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="MyBank")]
public partial class MyBankDataContext : System.Data.Linq.DataContext
{
	
	private static System.Data.Linq.Mapping.MappingSource mappingSource = new AttributeMappingSource();
	
  #region Extensibility Method Definitions
  partial void OnCreated();
  partial void InsertAccounts(Accounts instance);
  partial void UpdateAccounts(Accounts instance);
  partial void DeleteAccounts(Accounts instance);
  partial void InsertAccountStates(AccountStates instance);
  partial void UpdateAccountStates(AccountStates instance);
  partial void DeleteAccountStates(AccountStates instance);
  #endregion
	
	public MyBankDataContext() : 
			base(global::System.Configuration.ConfigurationManager.ConnectionStrings["MyBankConnectionString"].ConnectionString, mappingSource)
	{
		OnCreated();
	}
	
	public MyBankDataContext(string connection) : 
			base(connection, mappingSource)
	{
		OnCreated();
	}
	
	public MyBankDataContext(System.Data.IDbConnection connection) : 
			base(connection, mappingSource)
	{
		OnCreated();
	}
	
	public MyBankDataContext(string connection, System.Data.Linq.Mapping.MappingSource mappingSource) : 
			base(connection, mappingSource)
	{
		OnCreated();
	}
	
	public MyBankDataContext(System.Data.IDbConnection connection, System.Data.Linq.Mapping.MappingSource mappingSource) : 
			base(connection, mappingSource)
	{
		OnCreated();
	}
	
	public System.Data.Linq.Table<Accounts> Accounts
	{
		get
		{
			return this.GetTable<Accounts>();
		}
	}
	
	public System.Data.Linq.Table<AccountStates> AccountStates
	{
		get
		{
			return this.GetTable<AccountStates>();
		}
	}
}

[Table(Name="dbo.Accounts")]
public partial class Accounts : INotifyPropertyChanging, INotifyPropertyChanged
{
	
	private static PropertyChangingEventArgs emptyChangingEventArgs = new PropertyChangingEventArgs(String.Empty);
	
	private int _Id;
	
	private string _customerId;
	
	private string _customerPassword;
	
	private System.Nullable<decimal> _balance;
	
	private System.Nullable<int> _stateId;
	
	private EntityRef<AccountStates> _AccountStates;
	
    #region Extensibility Method Definitions
    partial void OnLoaded();
    partial void OnValidate(System.Data.Linq.ChangeAction action);
    partial void OnCreated();
    partial void OnIdChanging(int value);
    partial void OnIdChanged();
    partial void OncustomerIdChanging(string value);
    partial void OncustomerIdChanged();
    partial void OncustomerPasswordChanging(string value);
    partial void OncustomerPasswordChanged();
    partial void OnbalanceChanging(System.Nullable<decimal> value);
    partial void OnbalanceChanged();
    partial void OnstateIdChanging(System.Nullable<int> value);
    partial void OnstateIdChanged();
    #endregion
	
	public Accounts()
	{
		this._AccountStates = default(EntityRef<AccountStates>);
		OnCreated();
	}
	
	[Column(Storage="_Id", AutoSync=AutoSync.OnInsert, DbType="Int NOT NULL IDENTITY", IsPrimaryKey=true, IsDbGenerated=true)]
	public int Id
	{
		get
		{
			return this._Id;
		}
		set
		{
			if ((this._Id != value))
			{
				this.OnIdChanging(value);
				this.SendPropertyChanging();
				this._Id = value;
				this.SendPropertyChanged("Id");
				this.OnIdChanged();
			}
		}
	}
	
	[Column(Storage="_customerId", DbType="VarChar(50)")]
	public string customerId
	{
		get
		{
			return this._customerId;
		}
		set
		{
			if ((this._customerId != value))
			{
				this.OncustomerIdChanging(value);
				this.SendPropertyChanging();
				this._customerId = value;
				this.SendPropertyChanged("customerId");
				this.OncustomerIdChanged();
			}
		}
	}
	
	[Column(Storage="_customerPassword", DbType="VarChar(50)")]
	public string customerPassword
	{
		get
		{
			return this._customerPassword;
		}
		set
		{
			if ((this._customerPassword != value))
			{
				this.OncustomerPasswordChanging(value);
				this.SendPropertyChanging();
				this._customerPassword = value;
				this.SendPropertyChanged("customerPassword");
				this.OncustomerPasswordChanged();
			}
		}
	}
	
	[Column(Storage="_balance", DbType="Money")]
	public System.Nullable<decimal> balance
	{
		get
		{
			return this._balance;
		}
		set
		{
			if ((this._balance != value))
			{
				this.OnbalanceChanging(value);
				this.SendPropertyChanging();
				this._balance = value;
				this.SendPropertyChanged("balance");
				this.OnbalanceChanged();
			}
		}
	}
	
	[Column(Storage="_stateId", DbType="Int")]
	public System.Nullable<int> stateId
	{
		get
		{
			return this._stateId;
		}
		set
		{
			if ((this._stateId != value))
			{
				if (this._AccountStates.HasLoadedOrAssignedValue)
				{
					throw new System.Data.Linq.ForeignKeyReferenceAlreadyHasValueException();
				}
				this.OnstateIdChanging(value);
				this.SendPropertyChanging();
				this._stateId = value;
				this.SendPropertyChanged("stateId");
				this.OnstateIdChanged();
			}
		}
	}
	
	[Association(Name="AccountStates_Accounts", Storage="_AccountStates", ThisKey="stateId", IsForeignKey=true)]
	public AccountStates AccountStates
	{
		get
		{
			return this._AccountStates.Entity;
		}
		set
		{
			AccountStates previousValue = this._AccountStates.Entity;
			if (((previousValue != value) 
						|| (this._AccountStates.HasLoadedOrAssignedValue == false)))
			{
				this.SendPropertyChanging();
				if ((previousValue != null))
				{
					this._AccountStates.Entity = null;
					previousValue.Accounts.Remove(this);
				}
				this._AccountStates.Entity = value;
				if ((value != null))
				{
					value.Accounts.Add(this);
					this._stateId = value.Id;
				}
				else
				{
					this._stateId = default(Nullable<int>);
				}
				this.SendPropertyChanged("AccountStates");
			}
		}
	}
	
	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.AccountStates")]
public partial class AccountStates : INotifyPropertyChanging, INotifyPropertyChanged
{
	
	private static PropertyChangingEventArgs emptyChangingEventArgs = new PropertyChangingEventArgs(String.Empty);
	
	private int _Id;
	
	private string _name;
	
	private string _Description;
	
	private EntitySet<Accounts> _Accounts;
	
    #region Extensibility Method Definitions
    partial void OnLoaded();
    partial void OnValidate(System.Data.Linq.ChangeAction action);
    partial void OnCreated();
    partial void OnIdChanging(int value);
    partial void OnIdChanged();
    partial void OnnameChanging(string value);
    partial void OnnameChanged();
    partial void OnDescriptionChanging(string value);
    partial void OnDescriptionChanged();
    #endregion
	
	public AccountStates()
	{
		this._Accounts = new EntitySet<Accounts>(new Action<Accounts>(this.attach_Accounts), new Action<Accounts>(this.detach_Accounts));
		OnCreated();
	}
	
	[Column(Storage="_Id", AutoSync=AutoSync.OnInsert, DbType="Int NOT NULL IDENTITY", IsPrimaryKey=true, IsDbGenerated=true)]
	public int Id
	{
		get
		{
			return this._Id;
		}
		set
		{
			if ((this._Id != value))
			{
				this.OnIdChanging(value);
				this.SendPropertyChanging();
				this._Id = value;
				this.SendPropertyChanged("Id");
				this.OnIdChanged();
			}
		}
	}
	
	[Column(Storage="_name", DbType="VarChar(50)")]
	public string name
	{
		get
		{
			return this._name;
		}
		set
		{
			if ((this._name != value))
			{
				this.OnnameChanging(value);
				this.SendPropertyChanging();
				this._name = value;
				this.SendPropertyChanged("name");
				this.OnnameChanged();
			}
		}
	}
	
	[Column(Storage="_Description", DbType="VarChar(50)")]
	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();
			}
		}
	}
	
	[Association(Name="AccountStates_Accounts", Storage="_Accounts", OtherKey="stateId")]
	public EntitySet<Accounts> Accounts
	{
		get
		{
			return this._Accounts;
		}
		set
		{
			this._Accounts.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_Accounts(Accounts entity)
	{
		this.SendPropertyChanging();
		entity.AccountStates = this;
	}
	
	private void detach_Accounts(Accounts entity)
	{
		this.SendPropertyChanging();
		entity.AccountStates = null;
	}
}
#pragma warning restore 1591
