//------------------------------------------------------------------------------
// <autogenerated>
//     This code was generated by CodeSmith.
//     Version: 2.5.18.0
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </autogenerated>
//------------------------------------------------------------------------------
using System;
using System.IO;
using System.Collections;
using System.Data;
using System.Data.SqlClient;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Xml;
using System.Xml.Schema;
using System.Runtime.Serialization;

namespace TypedDataSetTester
{
	#region CustomersDataSet
	[Serializable()]
	[DesignerCategoryAttribute("code")]
	[System.Diagnostics.DebuggerStepThrough()]
	[ToolboxItem(true)]
	public class CustomersDataSet: DataSet
	{
		private CustomersDataTable _tableCustomers;
		
		[DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Content)]
		public CustomersDataTable Customers
		{
			get
			{
				return this._tableCustomers;
			}
		}
		
		public CustomersDataSet()
		{
			this.InitClass();
		}
		
		protected override XmlSchema GetSchemaSerializable() 
		{
			MemoryStream stream = new MemoryStream();
			this.WriteXmlSchema(new	XmlTextWriter(stream, null));
			stream.Position = 0;
			return XmlSchema.Read(new XmlTextReader(stream), null);
		}
		
		protected override void	ReadXmlSerializable(XmlReader reader) 
		{
			this.Reset();
			DataSet ds = new DataSet();
			ds.ReadXml(reader);
			if ((ds.Tables["Customers"] != null))
			{
				this.Tables.Add(new CustomersDataTable(ds.Tables["Customers"]));
			}
			this.DataSetName = ds.DataSetName;
			this.Prefix = ds.Prefix;
			this.Namespace = ds.Namespace;
			this.Locale = ds.Locale;
			this.CaseSensitive = ds.CaseSensitive;
			this.EnforceConstraints = ds.EnforceConstraints;
			this.Merge(ds, false, System.Data.MissingSchemaAction.Add);
			this.InitVars();
		}
		
		protected CustomersDataSet(SerializationInfo info, StreamingContext context)
		{
			string strSchema = ((string)(info.GetValue("XmlSchema", typeof(string))));
			if ((strSchema != null))
			{
				DataSet ds = new DataSet();
				ds.ReadXmlSchema(new XmlTextReader(new System.IO.StringReader(strSchema)));
				if ((ds.Tables["Customers"] != null))
				{
					this.Tables.Add(new CustomersDataTable(ds.Tables["Customers"]));
				}
				this.DataSetName = ds.DataSetName;
				this.Prefix = ds.Prefix;
				this.Namespace = ds.Namespace;
				this.Locale = ds.Locale;
				this.CaseSensitive = ds.CaseSensitive;
				this.EnforceConstraints = ds.EnforceConstraints;
				this.Merge(ds, false, System.Data.MissingSchemaAction.Add);
				this.InitVars();
			}
			else
			{
				this.InitClass();
			}
			this.GetSerializationData(info, context);
		}
		
		private void InitClass()
		{
			this.DataSetName = "CustomersDataSet";
			_tableCustomers = new CustomersDataTable();
			this.Tables.Add(_tableCustomers);
			this.ExtendedProperties.Add("DataAdapterName", "CustomersDataAdapter");
			this.ExtendedProperties.Add("ObjectName", "Customers");
			this.ExtendedProperties.Add("ObjectDescription", "Customers");
			this.ExtendedProperties.Add("NameSpace", "");
		}
		
		public override DataSet Clone()
		{
			CustomersDataSet cln = ((CustomersDataSet)(base.Clone()));
			cln.InitVars();
			return cln;
		}
		
		internal void InitVars()
		{
			_tableCustomers = ((CustomersDataTable)(this.Tables["Customers"]));
			if (_tableCustomers != null)
			{
				_tableCustomers.InitVars();
			}
		}
		
		protected override bool ShouldSerializeTables()
		{
			return false;
		}
		
		protected override bool ShouldSerializeRelations()
		{
			return false;
		}
		
		private bool ShouldSerializeCustomers()
		{
			return false;
		}
		
		public delegate void CustomersRowChangeEventHandler(object sender, CustomersRowChangeEventArgs e);
		
		[Serializable()]
		public class CustomersDataTable: DataTable, System.Collections.IEnumerable
		{
			private DataColumn _columnCustomerID;
			private DataColumn _columnCompanyName;
			private DataColumn _columnContactName;
			private DataColumn _columnContactTitle;
			private DataColumn _columnAddress;
			private DataColumn _columnCity;
			private DataColumn _columnRegion;
			private DataColumn _columnPostalCode;
			private DataColumn _columnCountry;
			private DataColumn _columnPhone;
			private DataColumn _columnFax;
			
			internal CustomersDataTable(): base("Customers")
			{
				this.InitClass();
			}
			
			protected CustomersDataTable(SerializationInfo info, StreamingContext context): base(info, context)
			{
				this.InitVars();
			}
			
			internal CustomersDataTable(DataTable table): base(table.TableName)
			{
				if (table.CaseSensitive != table.DataSet.CaseSensitive)
				{
					this.CaseSensitive = table.CaseSensitive;
				}
				if (table.Locale.ToString() != table.DataSet.Locale.ToString())
				{
					this.Locale = table.Locale;
				}
				if (table.Namespace != table.DataSet.Namespace)
				{
					this.Namespace = table.Namespace;
				}
				this.Prefix = table.Prefix;
				this.MinimumCapacity = table.MinimumCapacity;
				this.DisplayExpression = table.DisplayExpression;
			}
			
			public int Count
			{
				get
				{
					return this.Rows.Count;
				}
			}
			
			public DataColumn CustomerIDColumn
			{
				get
				{
					return _columnCustomerID;
				}
			}
			
			public DataColumn CompanyNameColumn
			{
				get
				{
					return _columnCompanyName;
				}
			}
			
			public DataColumn ContactNameColumn
			{
				get
				{
					return _columnContactName;
				}
			}
			
			public DataColumn ContactTitleColumn
			{
				get
				{
					return _columnContactTitle;
				}
			}
			
			public DataColumn AddressColumn
			{
				get
				{
					return _columnAddress;
				}
			}
			
			public DataColumn CityColumn
			{
				get
				{
					return _columnCity;
				}
			}
			
			public DataColumn RegionColumn
			{
				get
				{
					return _columnRegion;
				}
			}
			
			public DataColumn PostalCodeColumn
			{
				get
				{
					return _columnPostalCode;
				}
			}
			
			public DataColumn CountryColumn
			{
				get
				{
					return _columnCountry;
				}
			}
			
			public DataColumn PhoneColumn
			{
				get
				{
					return _columnPhone;
				}
			}
			
			public DataColumn FaxColumn
			{
				get
				{
					return _columnFax;
				}
			}
			
			public CustomersRow this[int index]
			{
				get
				{
					return ((CustomersRow)(this.Rows[index]));
				}
			}
			
			public event CustomersRowChangeEventHandler CustomersRowChanged;
			public event CustomersRowChangeEventHandler CustomersRowChanging;
			public event CustomersRowChangeEventHandler CustomersRowDeleted;
			public event CustomersRowChangeEventHandler CustomersRowDeleting;
			
			public void AddCustomersRow(CustomersRow row)
			{
				this.Rows.Add(row);
			}
			
			public CustomersRow AddCustomersRow(
					string customerID,
					string companyName,
					string contactName,
					string contactTitle,
					string address,
					string city,
					string region,
					string postalCode,
					string country,
					string phone,
					string fax
				)
			{
				CustomersRow rowCustomersRow = ((CustomersRow)(this.NewRow()));
				rowCustomersRow["CustomerID"] = customerID;
				rowCustomersRow["CompanyName"] = companyName;
				rowCustomersRow["ContactName"] = contactName;
				rowCustomersRow["ContactTitle"] = contactTitle;
				rowCustomersRow["Address"] = address;
				rowCustomersRow["City"] = city;
				rowCustomersRow["Region"] = region;
				rowCustomersRow["PostalCode"] = postalCode;
				rowCustomersRow["Country"] = country;
				rowCustomersRow["Phone"] = phone;
				rowCustomersRow["Fax"] = fax;
				this.Rows.Add(rowCustomersRow);
				return rowCustomersRow;
			}
			
			public CustomersRow FindByCustomerID(string customerID)
			{
				return ((CustomersRow)(this.Rows.Find(new object[] {customerID})));
			}
			
			public IEnumerator GetEnumerator()
			{
				return this.Rows.GetEnumerator();
			}
			
			public override DataTable Clone()
			{
				CustomersDataTable cln = ((CustomersDataTable)(base.Clone()));
				cln.InitVars();
				return cln;
			}
			
			internal void InitVars()
			{
				_columnCustomerID = this.Columns["CustomerID"];
				_columnCompanyName = this.Columns["CompanyName"];
				_columnContactName = this.Columns["ContactName"];
				_columnContactTitle = this.Columns["ContactTitle"];
				_columnAddress = this.Columns["Address"];
				_columnCity = this.Columns["City"];
				_columnRegion = this.Columns["Region"];
				_columnPostalCode = this.Columns["PostalCode"];
				_columnCountry = this.Columns["Country"];
				_columnPhone = this.Columns["Phone"];
				_columnFax = this.Columns["Fax"];
			}
			
			public void InitClass()
			{
				_columnCustomerID = new DataColumn("CustomerID", typeof(string), "", MappingType.Element);
				_columnCustomerID.AllowDBNull = false;
				_columnCustomerID.Caption = "Customer ID";
				_columnCustomerID.Unique = true;
				_columnCustomerID.DefaultValue = Convert.DBNull;
				_columnCustomerID.ExtendedProperties.Add("IsKey", "true");
				_columnCustomerID.ExtendedProperties.Add("ReadOnly", "false");
				_columnCustomerID.ExtendedProperties.Add("Description", "Customer ID");
				_columnCustomerID.ExtendedProperties.Add("Decimals", "0");
				_columnCustomerID.ExtendedProperties.Add("AllowDBNulls", "false");
				this.Columns.Add(_columnCustomerID);
				
				_columnCompanyName = new DataColumn("CompanyName", typeof(string), "", MappingType.Element);
				_columnCompanyName.AllowDBNull = false;
				_columnCompanyName.Caption = "Company Name";
				_columnCompanyName.MaxLength = 40;
				_columnCompanyName.Unique = false;
				_columnCompanyName.DefaultValue = Convert.DBNull;
				_columnCompanyName.ExtendedProperties.Add("IsKey", "false");
				_columnCompanyName.ExtendedProperties.Add("ReadOnly", "false");
				_columnCompanyName.ExtendedProperties.Add("Description", "Company Name");
				_columnCompanyName.ExtendedProperties.Add("Length", "40");
				_columnCompanyName.ExtendedProperties.Add("Decimals", "0");
				_columnCompanyName.ExtendedProperties.Add("AllowDBNulls", "false");
				this.Columns.Add(_columnCompanyName);
				
				_columnContactName = new DataColumn("ContactName", typeof(string), "", MappingType.Element);
				_columnContactName.AllowDBNull = true;
				_columnContactName.Caption = "Contact Name";
				_columnContactName.MaxLength = 30;
				_columnContactName.Unique = false;
				_columnContactName.DefaultValue = Convert.DBNull;
				_columnContactName.ExtendedProperties.Add("IsKey", "false");
				_columnContactName.ExtendedProperties.Add("ReadOnly", "false");
				_columnContactName.ExtendedProperties.Add("Description", "Contact Name");
				_columnContactName.ExtendedProperties.Add("Length", "30");
				_columnContactName.ExtendedProperties.Add("Decimals", "0");
				_columnContactName.ExtendedProperties.Add("AllowDBNulls", "true");
				this.Columns.Add(_columnContactName);
				
				_columnContactTitle = new DataColumn("ContactTitle", typeof(string), "", MappingType.Element);
				_columnContactTitle.AllowDBNull = true;
				_columnContactTitle.Caption = "Contact Title";
				_columnContactTitle.MaxLength = 30;
				_columnContactTitle.Unique = false;
				_columnContactTitle.DefaultValue = Convert.DBNull;
				_columnContactTitle.ExtendedProperties.Add("IsKey", "false");
				_columnContactTitle.ExtendedProperties.Add("ReadOnly", "false");
				_columnContactTitle.ExtendedProperties.Add("Description", "Contact Title");
				_columnContactTitle.ExtendedProperties.Add("Length", "30");
				_columnContactTitle.ExtendedProperties.Add("Decimals", "0");
				_columnContactTitle.ExtendedProperties.Add("AllowDBNulls", "true");
				this.Columns.Add(_columnContactTitle);
				
				_columnAddress = new DataColumn("Address", typeof(string), "", MappingType.Element);
				_columnAddress.AllowDBNull = true;
				_columnAddress.Caption = "Address";
				_columnAddress.MaxLength = 60;
				_columnAddress.Unique = false;
				_columnAddress.DefaultValue = Convert.DBNull;
				_columnAddress.ExtendedProperties.Add("IsKey", "false");
				_columnAddress.ExtendedProperties.Add("ReadOnly", "false");
				_columnAddress.ExtendedProperties.Add("Description", "Address");
				_columnAddress.ExtendedProperties.Add("Length", "60");
				_columnAddress.ExtendedProperties.Add("Decimals", "0");
				_columnAddress.ExtendedProperties.Add("AllowDBNulls", "true");
				this.Columns.Add(_columnAddress);
				
				_columnCity = new DataColumn("City", typeof(string), "", MappingType.Element);
				_columnCity.AllowDBNull = true;
				_columnCity.Caption = "City";
				_columnCity.MaxLength = 15;
				_columnCity.Unique = false;
				_columnCity.DefaultValue = Convert.DBNull;
				_columnCity.ExtendedProperties.Add("IsKey", "false");
				_columnCity.ExtendedProperties.Add("ReadOnly", "false");
				_columnCity.ExtendedProperties.Add("Description", "City");
				_columnCity.ExtendedProperties.Add("Length", "15");
				_columnCity.ExtendedProperties.Add("Decimals", "0");
				_columnCity.ExtendedProperties.Add("AllowDBNulls", "true");
				this.Columns.Add(_columnCity);
				
				_columnRegion = new DataColumn("Region", typeof(string), "", MappingType.Element);
				_columnRegion.AllowDBNull = true;
				_columnRegion.Caption = "Region";
				_columnRegion.MaxLength = 15;
				_columnRegion.Unique = false;
				_columnRegion.DefaultValue = Convert.DBNull;
				_columnRegion.ExtendedProperties.Add("IsKey", "false");
				_columnRegion.ExtendedProperties.Add("ReadOnly", "false");
				_columnRegion.ExtendedProperties.Add("Description", "Region");
				_columnRegion.ExtendedProperties.Add("Length", "15");
				_columnRegion.ExtendedProperties.Add("Decimals", "0");
				_columnRegion.ExtendedProperties.Add("AllowDBNulls", "true");
				this.Columns.Add(_columnRegion);
				
				_columnPostalCode = new DataColumn("PostalCode", typeof(string), "", MappingType.Element);
				_columnPostalCode.AllowDBNull = true;
				_columnPostalCode.Caption = "Postal Code";
				_columnPostalCode.MaxLength = 10;
				_columnPostalCode.Unique = false;
				_columnPostalCode.DefaultValue = Convert.DBNull;
				_columnPostalCode.ExtendedProperties.Add("IsKey", "false");
				_columnPostalCode.ExtendedProperties.Add("ReadOnly", "false");
				_columnPostalCode.ExtendedProperties.Add("Description", "Postal Code");
				_columnPostalCode.ExtendedProperties.Add("Length", "10");
				_columnPostalCode.ExtendedProperties.Add("Decimals", "0");
				_columnPostalCode.ExtendedProperties.Add("AllowDBNulls", "true");
				this.Columns.Add(_columnPostalCode);
				
				_columnCountry = new DataColumn("Country", typeof(string), "", MappingType.Element);
				_columnCountry.AllowDBNull = true;
				_columnCountry.Caption = "Country";
				_columnCountry.MaxLength = 15;
				_columnCountry.Unique = false;
				_columnCountry.DefaultValue = Convert.DBNull;
				_columnCountry.ExtendedProperties.Add("IsKey", "false");
				_columnCountry.ExtendedProperties.Add("ReadOnly", "false");
				_columnCountry.ExtendedProperties.Add("Description", "Country");
				_columnCountry.ExtendedProperties.Add("Length", "15");
				_columnCountry.ExtendedProperties.Add("Decimals", "0");
				_columnCountry.ExtendedProperties.Add("AllowDBNulls", "true");
				this.Columns.Add(_columnCountry);
				
				_columnPhone = new DataColumn("Phone", typeof(string), "", MappingType.Element);
				_columnPhone.AllowDBNull = true;
				_columnPhone.Caption = "Phone";
				_columnPhone.MaxLength = 24;
				_columnPhone.Unique = false;
				_columnPhone.DefaultValue = Convert.DBNull;
				_columnPhone.ExtendedProperties.Add("IsKey", "false");
				_columnPhone.ExtendedProperties.Add("ReadOnly", "false");
				_columnPhone.ExtendedProperties.Add("Description", "Phone");
				_columnPhone.ExtendedProperties.Add("Length", "24");
				_columnPhone.ExtendedProperties.Add("Decimals", "0");
				_columnPhone.ExtendedProperties.Add("AllowDBNulls", "true");
				this.Columns.Add(_columnPhone);
				
				_columnFax = new DataColumn("Fax", typeof(string), "", MappingType.Element);
				_columnFax.AllowDBNull = true;
				_columnFax.Caption = "Fax";
				_columnFax.MaxLength = 24;
				_columnFax.Unique = false;
				_columnFax.DefaultValue = Convert.DBNull;
				_columnFax.ExtendedProperties.Add("IsKey", "false");
				_columnFax.ExtendedProperties.Add("ReadOnly", "false");
				_columnFax.ExtendedProperties.Add("Description", "Fax");
				_columnFax.ExtendedProperties.Add("Length", "24");
				_columnFax.ExtendedProperties.Add("Decimals", "0");
				_columnFax.ExtendedProperties.Add("AllowDBNulls", "true");
				this.Columns.Add(_columnFax);
				
				this.PrimaryKey = new DataColumn[] {_columnCustomerID};
			}
			
			public CustomersRow NewCustomersRow()
			{
				CustomersRow rowCustomersRow = ((CustomersRow)(this.NewRow()));
				return rowCustomersRow;
			}
			
			protected override DataRow NewRowFromBuilder(DataRowBuilder builder)
			{
				return new CustomersRow(builder);
			}
			
			protected override Type GetRowType()
			{
				return typeof(CustomersRow);
			}
			
			protected override void OnRowChanged(DataRowChangeEventArgs e)
			{
				base.OnRowChanged(e);
				if (this.CustomersRowChanged != null)
				{
					this.CustomersRowChanged(this, new CustomersRowChangeEventArgs(((CustomersRow)(e.Row)), e.Action));
				}
			}
			
			protected override void OnRowChanging(DataRowChangeEventArgs e)
			{
				base.OnRowChanging(e);
				if (this.CustomersRowChanging != null)
				{
					this.CustomersRowChanging(this, new CustomersRowChangeEventArgs(((CustomersRow)(e.Row)), e.Action));
				}
			}
			
			protected override void OnRowDeleted(DataRowChangeEventArgs e)
			{
				base.OnRowDeleted(e);
				if (this.CustomersRowDeleted != null)
				{
					this.CustomersRowDeleted(this, new CustomersRowChangeEventArgs(((CustomersRow)(e.Row)), e.Action));
				}
			}
			
			protected override void OnRowDeleting(DataRowChangeEventArgs e)
			{
				base.OnRowDeleting(e);
				if (this.CustomersRowDeleting != null)
				{
					this.CustomersRowDeleting(this, new CustomersRowChangeEventArgs(((CustomersRow)(e.Row)), e.Action));
				}
			}
			
			public void RemoveCustomersRow(CustomersRow row)
			{
				this.Rows.Remove(row);
			}
		}
		
		public class CustomersRow: DataRow
		{
			private CustomersDataTable _tableCustomers;
			
			internal CustomersRow(DataRowBuilder rb): base(rb)
			{
				_tableCustomers = ((CustomersDataTable)(this.Table));
			}
			
			/// <summary>
			/// Gets or sets the value of CustomerID property
			/// </summary>
			public string CustomerID
			{
				get
				{
					try
					{
						return ((string)(this[_tableCustomers.CustomerIDColumn]));
					}
					catch (InvalidCastException exception)
					{
						throw new StrongTypingException("Cannot get value CustomerID because it is DBNull.", exception);
					}
				}
				set
				{
					this[_tableCustomers.CustomerIDColumn] = value;
				}
			}
			
			public bool IsCustomerIDNull()
			{
				return this.IsNull(_tableCustomers.CustomerIDColumn);
			}
			
			public void SetCustomerIDNull()
			{
				this[_tableCustomers.CustomerIDColumn] = Convert.DBNull;
			}
			
			/// <summary>
			/// Gets or sets the value of CompanyName property
			/// </summary>
			public string CompanyName
			{
				get
				{
					try
					{
						return ((string)(this[_tableCustomers.CompanyNameColumn]));
					}
					catch (InvalidCastException exception)
					{
						throw new StrongTypingException("Cannot get value CompanyName because it is DBNull.", exception);
					}
				}
				set
				{
					this[_tableCustomers.CompanyNameColumn] = value;
				}
			}
			
			public bool IsCompanyNameNull()
			{
				return this.IsNull(_tableCustomers.CompanyNameColumn);
			}
			
			public void SetCompanyNameNull()
			{
				this[_tableCustomers.CompanyNameColumn] = Convert.DBNull;
			}
			
			/// <summary>
			/// Gets or sets the value of ContactName property
			/// </summary>
			public string ContactName
			{
				get
				{
					try
					{
						return ((string)(this[_tableCustomers.ContactNameColumn]));
					}
					catch (InvalidCastException exception)
					{
						throw new StrongTypingException("Cannot get value ContactName because it is DBNull.", exception);
					}
				}
				set
				{
					this[_tableCustomers.ContactNameColumn] = value;
				}
			}
			
			public bool IsContactNameNull()
			{
				return this.IsNull(_tableCustomers.ContactNameColumn);
			}
			
			public void SetContactNameNull()
			{
				this[_tableCustomers.ContactNameColumn] = Convert.DBNull;
			}
			
			/// <summary>
			/// Gets or sets the value of ContactTitle property
			/// </summary>
			public string ContactTitle
			{
				get
				{
					try
					{
						return ((string)(this[_tableCustomers.ContactTitleColumn]));
					}
					catch (InvalidCastException exception)
					{
						throw new StrongTypingException("Cannot get value ContactTitle because it is DBNull.", exception);
					}
				}
				set
				{
					this[_tableCustomers.ContactTitleColumn] = value;
				}
			}
			
			public bool IsContactTitleNull()
			{
				return this.IsNull(_tableCustomers.ContactTitleColumn);
			}
			
			public void SetContactTitleNull()
			{
				this[_tableCustomers.ContactTitleColumn] = Convert.DBNull;
			}
			
			/// <summary>
			/// Gets or sets the value of Address property
			/// </summary>
			public string Address
			{
				get
				{
					try
					{
						return ((string)(this[_tableCustomers.AddressColumn]));
					}
					catch (InvalidCastException exception)
					{
						throw new StrongTypingException("Cannot get value Address because it is DBNull.", exception);
					}
				}
				set
				{
					this[_tableCustomers.AddressColumn] = value;
				}
			}
			
			public bool IsAddressNull()
			{
				return this.IsNull(_tableCustomers.AddressColumn);
			}
			
			public void SetAddressNull()
			{
				this[_tableCustomers.AddressColumn] = Convert.DBNull;
			}
			
			/// <summary>
			/// Gets or sets the value of City property
			/// </summary>
			public string City
			{
				get
				{
					try
					{
						return ((string)(this[_tableCustomers.CityColumn]));
					}
					catch (InvalidCastException exception)
					{
						throw new StrongTypingException("Cannot get value City because it is DBNull.", exception);
					}
				}
				set
				{
					this[_tableCustomers.CityColumn] = value;
				}
			}
			
			public bool IsCityNull()
			{
				return this.IsNull(_tableCustomers.CityColumn);
			}
			
			public void SetCityNull()
			{
				this[_tableCustomers.CityColumn] = Convert.DBNull;
			}
			
			/// <summary>
			/// Gets or sets the value of Region property
			/// </summary>
			public string Region
			{
				get
				{
					try
					{
						return ((string)(this[_tableCustomers.RegionColumn]));
					}
					catch (InvalidCastException exception)
					{
						throw new StrongTypingException("Cannot get value Region because it is DBNull.", exception);
					}
				}
				set
				{
					this[_tableCustomers.RegionColumn] = value;
				}
			}
			
			public bool IsRegionNull()
			{
				return this.IsNull(_tableCustomers.RegionColumn);
			}
			
			public void SetRegionNull()
			{
				this[_tableCustomers.RegionColumn] = Convert.DBNull;
			}
			
			/// <summary>
			/// Gets or sets the value of PostalCode property
			/// </summary>
			public string PostalCode
			{
				get
				{
					try
					{
						return ((string)(this[_tableCustomers.PostalCodeColumn]));
					}
					catch (InvalidCastException exception)
					{
						throw new StrongTypingException("Cannot get value PostalCode because it is DBNull.", exception);
					}
				}
				set
				{
					this[_tableCustomers.PostalCodeColumn] = value;
				}
			}
			
			public bool IsPostalCodeNull()
			{
				return this.IsNull(_tableCustomers.PostalCodeColumn);
			}
			
			public void SetPostalCodeNull()
			{
				this[_tableCustomers.PostalCodeColumn] = Convert.DBNull;
			}
			
			/// <summary>
			/// Gets or sets the value of Country property
			/// </summary>
			public string Country
			{
				get
				{
					try
					{
						return ((string)(this[_tableCustomers.CountryColumn]));
					}
					catch (InvalidCastException exception)
					{
						throw new StrongTypingException("Cannot get value Country because it is DBNull.", exception);
					}
				}
				set
				{
					this[_tableCustomers.CountryColumn] = value;
				}
			}
			
			public bool IsCountryNull()
			{
				return this.IsNull(_tableCustomers.CountryColumn);
			}
			
			public void SetCountryNull()
			{
				this[_tableCustomers.CountryColumn] = Convert.DBNull;
			}
			
			/// <summary>
			/// Gets or sets the value of Phone property
			/// </summary>
			public string Phone
			{
				get
				{
					try
					{
						return ((string)(this[_tableCustomers.PhoneColumn]));
					}
					catch (InvalidCastException exception)
					{
						throw new StrongTypingException("Cannot get value Phone because it is DBNull.", exception);
					}
				}
				set
				{
					this[_tableCustomers.PhoneColumn] = value;
				}
			}
			
			public bool IsPhoneNull()
			{
				return this.IsNull(_tableCustomers.PhoneColumn);
			}
			
			public void SetPhoneNull()
			{
				this[_tableCustomers.PhoneColumn] = Convert.DBNull;
			}
			
			/// <summary>
			/// Gets or sets the value of Fax property
			/// </summary>
			public string Fax
			{
				get
				{
					try
					{
						return ((string)(this[_tableCustomers.FaxColumn]));
					}
					catch (InvalidCastException exception)
					{
						throw new StrongTypingException("Cannot get value Fax because it is DBNull.", exception);
					}
				}
				set
				{
					this[_tableCustomers.FaxColumn] = value;
				}
			}
			
			public bool IsFaxNull()
			{
				return this.IsNull(_tableCustomers.FaxColumn);
			}
			
			public void SetFaxNull()
			{
				this[_tableCustomers.FaxColumn] = Convert.DBNull;
			}
			
		}
		
		public class CustomersRowChangeEventArgs: EventArgs
		{
			private CustomersRow _eventRow;
			private System.Data.DataRowAction _eventAction;
			
			public CustomersRowChangeEventArgs(CustomersRow row, DataRowAction action)
			{
				_eventRow = row;
				_eventAction = action;
			}
			
			public CustomersRow Row
			{
				get
				{
					return _eventRow;
				}
			}
			
			public DataRowAction Action
			{
				get
				{
					return _eventAction;
				}
			}
		}
	}
	#endregion
	
	#region CustomersDataAdapter
	public class CustomersDataAdapter: MarshalByRefObject, IDataAdapter
	{
		#region Member Variables
		private IDbConnection _connection;
		private IDbTransaction _transaction;
		private IDbCommand _command;
		private IDataReader _reader;
		private int _connectionTimeout = 30;
		private int _commandTimeout = 30;
		private string _connectionStringKey;
		private bool _autoCloseConnection = true;
		private bool _autoCommitTransaction = true;
		private bool _convertEmptyValuesToDBNull = true;
		//private IDataParameter[] _fillDataParameters;
		#endregion
		
		#region Constructors
		public CustomersDataAdapter(string connectionStringKey)
		{
			_connectionStringKey = connectionStringKey;
		}
		
		public CustomersDataAdapter(IDbConnection connection)
		{
			this.Connection = connection;
		}
		
		public CustomersDataAdapter(IDbTransaction transaction)
		{
			this.Transaction = transaction;
		}
		#endregion
		
		#region Properties
		public IDbConnection Connection
		{
			get
			{
				if (_connection == null)
				{
					_connection = new SqlConnection();
					_connection.ConnectionString = System.Configuration.ConfigurationSettings.AppSettings[this.ConnectionStringKey];;
					//_connection.ConnectionTimeout = this.ConnectionTimeout;
				}
				return _connection;
			}
			set
			{
				_connection = value;
				// if the connection is passed in then it should be up to the owner to close the connection.
				_autoCloseConnection = false;
			}
		}
		
		public IDbTransaction Transaction
		{
			get	{return _transaction;}
			set
			{
				_transaction = value;
				_connection = _transaction.Connection;
				// if the connection is passed in then it should be up to the owner to close the connection.
				_autoCloseConnection = false;
				// if the transaction is passed in then it should be up to the owner of the transaction to commit.
				_autoCommitTransaction = false;
			}
		}
		
		public bool AutoCloseConnection
		{
			get {return _autoCloseConnection;}
			set {_autoCloseConnection = value;}
		}
		
		public bool AutoCommitTransaction
		{
			get {return _autoCommitTransaction;}
			set {_autoCommitTransaction = value;}
		}
		
		public bool ConvertEmptyValuesToDBNull
		{
			get {return _convertEmptyValuesToDBNull;}
			set {_convertEmptyValuesToDBNull = value;}
		}
		
		public string ConnectionStringKey
		{
			get {return _connectionStringKey;}
		}
		
		public int ConnectionTimeout
		{
			get	{return _connectionTimeout;}
			set	{_connectionTimeout = value;}
		}
		
		public int CommandTimeout
		{
			get	{return _commandTimeout;}
			set	{_commandTimeout = value;}
		}
		
		public MissingMappingAction MissingMappingAction
		{
			get	{return MissingMappingAction.Passthrough;}
			set {}
		}
		
		public MissingSchemaAction MissingSchemaAction
		{
			get	{return MissingSchemaAction.Ignore;}
			set	{}
		}
		
		public ITableMappingCollection TableMappings
		{
			get
			{
				System.Data.Common.DataTableMappingCollection tableMaps;
				tableMaps = new System.Data.Common.DataTableMappingCollection();
				return tableMaps;
			}
		}
		#endregion
		
		#region Helper Methods
		private IDbCommand GetCommand()
		{
			if (this.Connection != null)
			{
				_command = this.Connection.CreateCommand();
				_command.CommandTimeout = this.CommandTimeout;
				_command.CommandType = CommandType.Text;
				_command.Connection = this.Connection;
				if (_transaction != null) _command.Transaction = _transaction;
				
				return _command;
			}
			else
			{
				throw new InvalidOperationException("You must have a valid Connection object before calling GetCommand.");
			}
		}
		
		private void OpenConnection()
		{
			if (this.Connection != null)
			{
				if (this.Connection.State == ConnectionState.Closed) _connection.Open();
			}
			else
			{
				throw new InvalidOperationException("You must have a valid Connection object before calling GetCommand.");
			}
		}

		private void Cleanup()
		{
			try
			{
				if (_reader != null)
				{
					if (!_reader.IsClosed) _reader.Close();
					_reader.Dispose();
					_reader = null;
				}
				
				if (_command != null)
				{
					_command.Dispose();
					_command = null;
				}
				
				if (_connection != null && this.AutoCloseConnection == true)
				{
					if (_connection.State == ConnectionState.Open) _connection.Close();
					_connection.Dispose();
					_connection = null;
				}
			}
			catch {}
		}
		#endregion
		
		#region CreateParameter
		public IDbDataParameter CreateParameter(string name, DbType type, object value)
		{
			IDbDataParameter prm = _command.CreateParameter();
			prm.Direction = ParameterDirection.Input;
			prm.ParameterName = name;
			prm.DbType = type;
			prm.Value = this.PrepareParameterValue(value);
			
			return prm;
		}
		
		public IDbDataParameter CreateParameter(string name, DbType type, object value, int size)
		{
			IDbDataParameter prm = _command.CreateParameter();
			prm.Direction = ParameterDirection.Input;
			prm.ParameterName = name;
			prm.DbType = type;
			prm.Size = size;
			prm.Value = this.PrepareParameterValue(value);
			
			return prm;
		}
		
		public IDbDataParameter CreateParameter(string name, DbType type, object value, ParameterDirection direction)
		{
			IDbDataParameter prm = _command.CreateParameter();
			prm.Direction = direction;
			prm.ParameterName = name;
			prm.DbType = type;
			prm.Value = this.PrepareParameterValue(value);
			
			return prm;
		}
		
		public IDbDataParameter CreateParameter(string name, DbType type, object value, int size, ParameterDirection direction)
		{
			IDbDataParameter prm = _command.CreateParameter();
			prm.Direction = direction;
			prm.ParameterName = name;
			prm.DbType = type;
			prm.Size = size;
			prm.Value = this.PrepareParameterValue(value);
			
			return prm;
		}
		
		private object PrepareParameterValue(object value)
		{
			return PrepareParameterValue(value, false);
		}
		
		private object PrepareParameterValue(object value, bool convertZeroToDBNull)
		{
			if (!_convertEmptyValuesToDBNull) return value;
			
			switch (value.GetType().ToString())
			{
				case "System.String":
					if (Convert.ToString(value) == String.Empty)
					{
						return DBNull.Value;
					}
					else
					{
						return value;
					}
				case "System.Guid":
					if (new Guid(Convert.ToString(value)) == Guid.Empty)
					{
						return DBNull.Value;
					}
					else
					{
						return value;
					}
				case "System.DateTime":
					if (Convert.ToDateTime(value) == DateTime.MinValue)
					{
						return DBNull.Value;
					}
					else
					{
						return value;
					}
				case "System.Int16":
					if (Convert.ToInt16(value) == 0)
					{
						if (convertZeroToDBNull)
						{
							return DBNull.Value;
						}
						else
						{
							return value;
						}
					}
					else
					{
						return value;
					}
				case "System.Int32":
					if (Convert.ToInt32(value) == 0)
					{
						if (convertZeroToDBNull)
						{
							return DBNull.Value;
						}
						else
						{
							return value;
						}
					}
					else
					{
						return value;
					}
				case "System.Int64":
					if (Convert.ToInt64(value) == 0)
					{
						if (convertZeroToDBNull)
						{
							return DBNull.Value;
						}
						else
						{
							return value;
						}
					}
					else
					{
						return value;
					}
				case "System.Single":
					if (Convert.ToSingle(value) == 0)
					{
						if (convertZeroToDBNull)
						{
							return DBNull.Value;
						}
						else
						{
							return value;
						}
					}
					else
					{
						return value;
					}
				case "System.Double":
					if (Convert.ToDouble(value) == 0)
					{
						if (convertZeroToDBNull)
						{
							return DBNull.Value;
						}
						else
						{
							return value;
						}
					}
					else
					{
						return value;
					}
				case "System.Decimal":
					if (Convert.ToDecimal(value) == 0)
					{
						if (convertZeroToDBNull)
						{
							return DBNull.Value;
						}
						else
						{
							return value;
						}
					}
					else
					{
						return value;
					}
				default:
					return value;
			}
		}
		#endregion AddParameter
		
		#region Fill Methods
		public DataTable[] FillSchema(DataSet dataSet, SchemaType schemaType)
		{
			DataTable[] dataTables;
			dataTables = new DataTable[dataSet.Tables.Count];
			dataSet.Tables.CopyTo(dataTables, dataSet.Tables.Count);
			return dataTables;
		}
		
		public int Fill(CustomersDataSet dataSet, IDataRecord dataRecord)
		{
			return Fill(dataSet, ((string)(dataRecord["CustomerID"])));
		}
		
		public int Fill(CustomersDataSet dataSet, DataRow dataRecord)
		{
			return Fill(dataSet, ((string)(dataRecord["CustomerID"])));
		}
		
		public int Fill(CustomersDataSet dataSet, string customerID)
		{
			try
			{
				_command = this.GetCommand();
				_command.CommandText = @"
					SELECT
						[CustomerID],
						[CompanyName],
						[ContactName],
						[ContactTitle],
						[Address],
						[City],
						[Region],
						[PostalCode],
						[Country],
						[Phone],
						[Fax]
					FROM
						[Customers]
					WHERE
						[CustomerID] = @CustomerID
					";
				_command.Parameters.Add(this.CreateParameter("@CustomerID", DbType.StringFixedLength, customerID));
				this.OpenConnection();
				_reader = _command.ExecuteReader(CommandBehavior.CloseConnection | CommandBehavior.SingleResult | CommandBehavior.SingleRow);
				if (_reader.Read())
				{
					CustomersDataSet.CustomersRow row = dataSet.Customers.NewCustomersRow();
					this.PopulateCustomersDataRow(_reader, row);
					dataSet.Customers.AddCustomersRow(row);
					dataSet.AcceptChanges();
					
					return 1;
				}
				else
				{
					throw new CustomersNotFoundException();
				}
			}
			catch (Exception e)
			{
				System.Diagnostics.Debug.WriteLine(e.ToString());
				return 0;
			}
			finally
			{
				this.Cleanup();
			}
		}
		
		private void PopulateCustomersDataRow(IDataReader reader, CustomersDataSet.CustomersRow row)
		{
			if (!reader.IsDBNull(0)) row.CustomerID = reader.GetString(0);
			if (!reader.IsDBNull(1)) row.CompanyName = reader.GetString(1);
			if (!reader.IsDBNull(2)) row.ContactName = reader.GetString(2);
			if (!reader.IsDBNull(3)) row.ContactTitle = reader.GetString(3);
			if (!reader.IsDBNull(4)) row.Address = reader.GetString(4);
			if (!reader.IsDBNull(5)) row.City = reader.GetString(5);
			if (!reader.IsDBNull(6)) row.Region = reader.GetString(6);
			if (!reader.IsDBNull(7)) row.PostalCode = reader.GetString(7);
			if (!reader.IsDBNull(8)) row.Country = reader.GetString(8);
			if (!reader.IsDBNull(9)) row.Phone = reader.GetString(9);
			if (!reader.IsDBNull(10)) row.Fax = reader.GetString(10);
		}
		
		public int Fill(DataSet dataSet)
		{
			CustomersDataSet pageDataSet = dataSet as CustomersDataSet;
			if (pageDataSet != null)
			{
				return this.Fill(pageDataSet);
			}
			else
			{
				throw new ApplicationException();
			}
		}
		
		public int Fill(CustomersDataSet dataSet)
		{
			try
			{
				int recordcount = 0;
				_command = this.GetCommand();
				_command.CommandText = @"
					SELECT
						[CustomerID],
						[CompanyName],
						[ContactName],
						[ContactTitle],
						[Address],
						[City],
						[Region],
						[PostalCode],
						[Country],
						[Phone],
						[Fax]
					FROM
						[Customers]";
				this.OpenConnection();
				_reader = _command.ExecuteReader(CommandBehavior.CloseConnection | CommandBehavior.SingleResult);
				while (_reader.Read())
				{
					CustomersDataSet.CustomersRow row = dataSet.Customers.NewCustomersRow();
					this.PopulateCustomersDataRow(_reader, row);
					dataSet.Customers.AddCustomersRow(row);
					
					recordcount++;
				}
				dataSet.AcceptChanges();
				
				return recordcount;
			}
			catch (Exception e)
			{
				System.Diagnostics.Debug.WriteLine(e.ToString());
				return 0;
			}
			finally
			{
				this.Cleanup();
			}
		}
		
		public IDataParameter[] GetFillParameters()
		{
			// not sure if I should create a CustomersId parameter here or not.
			return null; //_fillDataParameters;
		}
		#endregion
		
		#region Update Methods
		public int Update(DataSet dataSet)
		{
			CustomersDataSet pageDataSet = dataSet as CustomersDataSet;
			if (pageDataSet != null)
			{
				return this.Update(pageDataSet);
			}
			else
			{
				throw new ApplicationException();
			}
		}
		
		public int Update(CustomersDataSet dataSet)
		{
			if (dataSet != null)
			{
				try
				{
					int updatedRowCount = 0;
					
					foreach(CustomersDataSet.CustomersRow row in dataSet.Customers)
					{
						switch (row.RowState)
						{
							case DataRowState.Added:
							{
								OnCustomersUpdating(new CustomersEventArgs(row, StatementType.Insert)) ;
								_command = this.GetCommand();
								_command.CommandText = @"
									INSERT INTO [Customers] (
										[CustomerID],
										[CompanyName],
										[ContactName],
										[ContactTitle],
										[Address],
										[City],
										[Region],
										[PostalCode],
										[Country],
										[Phone],
										[Fax]
									) VALUES (
										@CustomerID,
										@CompanyName,
										@ContactName,
										@ContactTitle,
										@Address,
										@City,
										@Region,
										@PostalCode,
										@Country,
										@Phone,
										@Fax
									)";
								_command.Parameters.Add(this.CreateParameter("@CustomerID", DbType.StringFixedLength, row.IsCustomerIDNull() ? (object)DBNull.Value : (object)row.CustomerID));
								_command.Parameters.Add(this.CreateParameter("@CompanyName", DbType.String, row.IsCompanyNameNull() ? (object)DBNull.Value : (object)row.CompanyName));
								_command.Parameters.Add(this.CreateParameter("@ContactName", DbType.String, row.IsContactNameNull() ? (object)DBNull.Value : (object)row.ContactName));
								_command.Parameters.Add(this.CreateParameter("@ContactTitle", DbType.String, row.IsContactTitleNull() ? (object)DBNull.Value : (object)row.ContactTitle));
								_command.Parameters.Add(this.CreateParameter("@Address", DbType.String, row.IsAddressNull() ? (object)DBNull.Value : (object)row.Address));
								_command.Parameters.Add(this.CreateParameter("@City", DbType.String, row.IsCityNull() ? (object)DBNull.Value : (object)row.City));
								_command.Parameters.Add(this.CreateParameter("@Region", DbType.String, row.IsRegionNull() ? (object)DBNull.Value : (object)row.Region));
								_command.Parameters.Add(this.CreateParameter("@PostalCode", DbType.String, row.IsPostalCodeNull() ? (object)DBNull.Value : (object)row.PostalCode));
								_command.Parameters.Add(this.CreateParameter("@Country", DbType.String, row.IsCountryNull() ? (object)DBNull.Value : (object)row.Country));
								_command.Parameters.Add(this.CreateParameter("@Phone", DbType.String, row.IsPhoneNull() ? (object)DBNull.Value : (object)row.Phone));
								_command.Parameters.Add(this.CreateParameter("@Fax", DbType.String, row.IsFaxNull() ? (object)DBNull.Value : (object)row.Fax));
								this.OpenConnection();
								_command.ExecuteNonQuery();
								OnCustomersUpdated(new CustomersEventArgs(row, StatementType.Insert)) ;
								
								updatedRowCount++;
								break;
							}
							case DataRowState.Modified:
							{
								OnCustomersUpdating(new CustomersEventArgs(row, StatementType.Update)) ;
								_command = this.GetCommand();
								_command.CommandText = @"
									UPDATE [Customers] SET
										[CompanyName] = @CompanyName,
										[ContactName] = @ContactName,
										[ContactTitle] = @ContactTitle,
										[Address] = @Address,
										[City] = @City,
										[Region] = @Region,
										[PostalCode] = @PostalCode,
										[Country] = @Country,
										[Phone] = @Phone,
										[Fax] = @Fax
									WHERE
										[CustomerID] = @CustomerID
									";
								_command.Parameters.Add(this.CreateParameter("@CustomerID", DbType.StringFixedLength, row.IsCustomerIDNull() ? (object)DBNull.Value : (object)row.CustomerID));
								_command.Parameters.Add(this.CreateParameter("@CompanyName", DbType.String, row.IsCompanyNameNull() ? (object)DBNull.Value : (object)row.CompanyName));
								_command.Parameters.Add(this.CreateParameter("@ContactName", DbType.String, row.IsContactNameNull() ? (object)DBNull.Value : (object)row.ContactName));
								_command.Parameters.Add(this.CreateParameter("@ContactTitle", DbType.String, row.IsContactTitleNull() ? (object)DBNull.Value : (object)row.ContactTitle));
								_command.Parameters.Add(this.CreateParameter("@Address", DbType.String, row.IsAddressNull() ? (object)DBNull.Value : (object)row.Address));
								_command.Parameters.Add(this.CreateParameter("@City", DbType.String, row.IsCityNull() ? (object)DBNull.Value : (object)row.City));
								_command.Parameters.Add(this.CreateParameter("@Region", DbType.String, row.IsRegionNull() ? (object)DBNull.Value : (object)row.Region));
								_command.Parameters.Add(this.CreateParameter("@PostalCode", DbType.String, row.IsPostalCodeNull() ? (object)DBNull.Value : (object)row.PostalCode));
								_command.Parameters.Add(this.CreateParameter("@Country", DbType.String, row.IsCountryNull() ? (object)DBNull.Value : (object)row.Country));
								_command.Parameters.Add(this.CreateParameter("@Phone", DbType.String, row.IsPhoneNull() ? (object)DBNull.Value : (object)row.Phone));
								_command.Parameters.Add(this.CreateParameter("@Fax", DbType.String, row.IsFaxNull() ? (object)DBNull.Value : (object)row.Fax));
								this.OpenConnection();
								_command.ExecuteNonQuery();
								OnCustomersUpdated(new CustomersEventArgs(row, StatementType.Update)) ;
								
								updatedRowCount++;
								break;
							}
							case DataRowState.Deleted:
							{
								OnCustomersUpdating(new CustomersEventArgs(row, StatementType.Delete)) ;
								_command = this.GetCommand();
								_command.CommandText = @"
									DELETE FROM [Customers]
									WHERE
										[CustomerID] = @CustomerID
									";
								_command.Parameters.Add(this.CreateParameter("@CustomerID", DbType.StringFixedLength, row[dataSet.Customers.CustomerIDColumn, DataRowVersion.Original]));
								this.OpenConnection();
								_command.ExecuteNonQuery();
								OnCustomersUpdated(new CustomersEventArgs(row, StatementType.Delete)) ;
								
								updatedRowCount++;
								break;
							}
						}
					}
					dataSet.AcceptChanges();
					
					return updatedRowCount;
				}
				catch (Exception e)
				{
					System.Diagnostics.Debug.WriteLine(e.ToString());
					return 0;
				}
				finally
				{
					this.Cleanup();
				}
			}
			else
			{
				this.Cleanup();
				throw new ArgumentException("DataSet null");
			}
		}
		#endregion
		
		#region Events
		public delegate void CustomersUpdateEventHandler(object sender, CustomersEventArgs e);
		
		public event CustomersUpdateEventHandler CustomersUpdated;
		private void OnCustomersUpdated(CustomersEventArgs e)
		{
			if ((this.CustomersUpdated != null))
			{
				this.CustomersUpdated(this, e);
			}
		}
		
		public event CustomersUpdateEventHandler CustomersUpdating;
		private void OnCustomersUpdating(CustomersEventArgs e)
		{
			if ((this.CustomersUpdating != null))
			{
				this.CustomersUpdating(this, e);
			}
		}
		
		public class CustomersEventArgs : EventArgs
		{
			private StatementType _statementType;
			private CustomersDataSet.CustomersRow _dataRow;
			
			public CustomersEventArgs(CustomersDataSet.CustomersRow row, StatementType statementType)
			{
				_dataRow = row;
				_statementType = statementType;
			}
			
			public StatementType StatementType
			{
				get {return _statementType;}

			}
			
			public CustomersDataSet.CustomersRow Row
			{
				get {return _dataRow;}
				set	{_dataRow = value;}
			}
		}
		#endregion
		
		#region Custom Exceptions
		[Serializable()]
		public class CustomersNotFoundException: ApplicationException
		{
			public CustomersNotFoundException()
			{
			}
			
			public CustomersNotFoundException(string message) : base(message)
			{
			}
			
			public CustomersNotFoundException(string message, Exception inner): base(message, inner)
			{
			}
			
			protected CustomersNotFoundException(SerializationInfo info, StreamingContext context): base(info, context)
			{
			}
		}
		
		[Serializable()]
		public class ForeignKeyNotFoundException: ApplicationException
		{
			public ForeignKeyNotFoundException()
			{
			}
			
			public ForeignKeyNotFoundException(string message): base(message)
			{
			}
			
			public ForeignKeyNotFoundException(string message, Exception inner): base(message, inner)
			{
			}
			
			protected ForeignKeyNotFoundException(SerializationInfo info, StreamingContext context): base(info, context)
			{
			}
		}
		
		[Serializable()]
		public class CustomersDataLockedException: ApplicationException
		{
			public CustomersDataLockedException()
			{
			}
			
			public CustomersDataLockedException(string message): base(message)
			{
			}
			
			public CustomersDataLockedException(string message, Exception inner): base(message, inner)
			{
			}
			
			protected CustomersDataLockedException(SerializationInfo info, StreamingContext context): base(info, context)
			{
			}
		}

		[Serializable()]
		public class CustomersDataChangedException: ApplicationException
		{
			public CustomersDataChangedException()
			{
			}
			
			public CustomersDataChangedException(string message): base(message)
			{
			}
			
			public CustomersDataChangedException(string message, Exception inner): base(message, inner)
			{
			}
			
			protected CustomersDataChangedException(SerializationInfo info, StreamingContext context): base(info, context)
			{
			}
		}
		
		[Serializable()]
		public class CustomersDuplicateKeyException: ApplicationException
		{
			public CustomersDuplicateKeyException()
			{
			}
			
			public CustomersDuplicateKeyException(string message): base(message)
			{
			}
			
			public CustomersDuplicateKeyException(string message, Exception inner): base(message, inner)
			{
			}
			
			protected CustomersDuplicateKeyException(SerializationInfo info, StreamingContext context): base(info, context)
			{
			}
		}
		
		[Serializable()]
		public class CustomersDataDeletedException: ApplicationException
		{
			public CustomersDataDeletedException()
			{
			}
			
			public CustomersDataDeletedException(string message) : base(message)
			{
			}
			
			public CustomersDataDeletedException(string message, Exception inner): base(message, inner)
			{
			}
			
			protected CustomersDataDeletedException(SerializationInfo info, StreamingContext context): base(info, context)
			{
			}
		}
		#endregion
	}
	#endregion
	
	#region OrdersDataSet
	[Serializable()]
	[DesignerCategoryAttribute("code")]
	[System.Diagnostics.DebuggerStepThrough()]
	[ToolboxItem(true)]
	public class OrdersDataSet: DataSet
	{
		private OrdersDataTable _tableOrders;
		
		[DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Content)]
		public OrdersDataTable Orders
		{
			get
			{
				return this._tableOrders;
			}
		}
		
		public OrdersDataSet()
		{
			this.InitClass();
		}
		
		protected override XmlSchema GetSchemaSerializable() 
		{
			MemoryStream stream = new MemoryStream();
			this.WriteXmlSchema(new	XmlTextWriter(stream, null));
			stream.Position = 0;
			return XmlSchema.Read(new XmlTextReader(stream), null);
		}
		
		protected override void	ReadXmlSerializable(XmlReader reader) 
		{
			this.Reset();
			DataSet ds = new DataSet();
			ds.ReadXml(reader);
			if ((ds.Tables["Orders"] != null))
			{
				this.Tables.Add(new OrdersDataTable(ds.Tables["Orders"]));
			}
			this.DataSetName = ds.DataSetName;
			this.Prefix = ds.Prefix;
			this.Namespace = ds.Namespace;
			this.Locale = ds.Locale;
			this.CaseSensitive = ds.CaseSensitive;
			this.EnforceConstraints = ds.EnforceConstraints;
			this.Merge(ds, false, System.Data.MissingSchemaAction.Add);
			this.InitVars();
		}
		
		protected OrdersDataSet(SerializationInfo info, StreamingContext context)
		{
			string strSchema = ((string)(info.GetValue("XmlSchema", typeof(string))));
			if ((strSchema != null))
			{
				DataSet ds = new DataSet();
				ds.ReadXmlSchema(new XmlTextReader(new System.IO.StringReader(strSchema)));
				if ((ds.Tables["Orders"] != null))
				{
					this.Tables.Add(new OrdersDataTable(ds.Tables["Orders"]));
				}
				this.DataSetName = ds.DataSetName;
				this.Prefix = ds.Prefix;
				this.Namespace = ds.Namespace;
				this.Locale = ds.Locale;
				this.CaseSensitive = ds.CaseSensitive;
				this.EnforceConstraints = ds.EnforceConstraints;
				this.Merge(ds, false, System.Data.MissingSchemaAction.Add);
				this.InitVars();
			}
			else
			{
				this.InitClass();
			}
			this.GetSerializationData(info, context);
		}
		
		private void InitClass()
		{
			this.DataSetName = "OrdersDataSet";
			_tableOrders = new OrdersDataTable();
			this.Tables.Add(_tableOrders);
			this.ExtendedProperties.Add("DataAdapterName", "OrdersDataAdapter");
			this.ExtendedProperties.Add("ObjectName", "Orders");
			this.ExtendedProperties.Add("ObjectDescription", "Orders");
			this.ExtendedProperties.Add("NameSpace", "");
		}
		
		public override DataSet Clone()
		{
			OrdersDataSet cln = ((OrdersDataSet)(base.Clone()));
			cln.InitVars();
			return cln;
		}
		
		internal void InitVars()
		{
			_tableOrders = ((OrdersDataTable)(this.Tables["Orders"]));
			if (_tableOrders != null)
			{
				_tableOrders.InitVars();
			}
		}
		
		protected override bool ShouldSerializeTables()
		{
			return false;
		}
		
		protected override bool ShouldSerializeRelations()
		{
			return false;
		}
		
		private bool ShouldSerializeOrders()
		{
			return false;
		}
		
		public delegate void OrdersRowChangeEventHandler(object sender, OrdersRowChangeEventArgs e);
		
		[Serializable()]
		public class OrdersDataTable: DataTable, System.Collections.IEnumerable
		{
			private DataColumn _columnOrderID;
			private DataColumn _columnCustomerID;
			private DataColumn _columnEmployeeID;
			private DataColumn _columnOrderDate;
			private DataColumn _columnRequiredDate;
			private DataColumn _columnShippedDate;
			private DataColumn _columnShipVia;
			private DataColumn _columnFreight;
			private DataColumn _columnShipName;
			private DataColumn _columnShipAddress;
			private DataColumn _columnShipCity;
			private DataColumn _columnShipRegion;
			private DataColumn _columnShipPostalCode;
			private DataColumn _columnShipCountry;
			
			internal OrdersDataTable(): base("Orders")
			{
				this.InitClass();
			}
			
			protected OrdersDataTable(SerializationInfo info, StreamingContext context): base(info, context)
			{
				this.InitVars();
			}
			
			internal OrdersDataTable(DataTable table): base(table.TableName)
			{
				if (table.CaseSensitive != table.DataSet.CaseSensitive)
				{
					this.CaseSensitive = table.CaseSensitive;
				}
				if (table.Locale.ToString() != table.DataSet.Locale.ToString())
				{
					this.Locale = table.Locale;
				}
				if (table.Namespace != table.DataSet.Namespace)
				{
					this.Namespace = table.Namespace;
				}
				this.Prefix = table.Prefix;
				this.MinimumCapacity = table.MinimumCapacity;
				this.DisplayExpression = table.DisplayExpression;
			}
			
			public int Count
			{
				get
				{
					return this.Rows.Count;
				}
			}
			
			public DataColumn OrderIDColumn
			{
				get
				{
					return _columnOrderID;
				}
			}
			
			public DataColumn CustomerIDColumn
			{
				get
				{
					return _columnCustomerID;
				}
			}
			
			public DataColumn EmployeeIDColumn
			{
				get
				{
					return _columnEmployeeID;
				}
			}
			
			public DataColumn OrderDateColumn
			{
				get
				{
					return _columnOrderDate;
				}
			}
			
			public DataColumn RequiredDateColumn
			{
				get
				{
					return _columnRequiredDate;
				}
			}
			
			public DataColumn ShippedDateColumn
			{
				get
				{
					return _columnShippedDate;
				}
			}
			
			public DataColumn ShipViaColumn
			{
				get
				{
					return _columnShipVia;
				}
			}
			
			public DataColumn FreightColumn
			{
				get
				{
					return _columnFreight;
				}
			}
			
			public DataColumn ShipNameColumn
			{
				get
				{
					return _columnShipName;
				}
			}
			
			public DataColumn ShipAddressColumn
			{
				get
				{
					return _columnShipAddress;
				}
			}
			
			public DataColumn ShipCityColumn
			{
				get
				{
					return _columnShipCity;
				}
			}
			
			public DataColumn ShipRegionColumn
			{
				get
				{
					return _columnShipRegion;
				}
			}
			
			public DataColumn ShipPostalCodeColumn
			{
				get
				{
					return _columnShipPostalCode;
				}
			}
			
			public DataColumn ShipCountryColumn
			{
				get
				{
					return _columnShipCountry;
				}
			}
			
			public OrdersRow this[int index]
			{
				get
				{
					return ((OrdersRow)(this.Rows[index]));
				}
			}
			
			public event OrdersRowChangeEventHandler OrdersRowChanged;
			public event OrdersRowChangeEventHandler OrdersRowChanging;
			public event OrdersRowChangeEventHandler OrdersRowDeleted;
			public event OrdersRowChangeEventHandler OrdersRowDeleting;
			
			public void AddOrdersRow(OrdersRow row)
			{
				this.Rows.Add(row);
			}
			
			public OrdersRow AddOrdersRow(
					int orderID,
					string customerID,
					int employeeID,
					DateTime orderDate,
					DateTime requiredDate,
					DateTime shippedDate,
					int shipVia,
					decimal freight,
					string shipName,
					string shipAddress,
					string shipCity,
					string shipRegion,
					string shipPostalCode,
					string shipCountry
				)
			{
				OrdersRow rowOrdersRow = ((OrdersRow)(this.NewRow()));
				rowOrdersRow["OrderID"] = orderID;
				rowOrdersRow["CustomerID"] = customerID;
				rowOrdersRow["EmployeeID"] = employeeID;
				rowOrdersRow["OrderDate"] = orderDate;
				rowOrdersRow["RequiredDate"] = requiredDate;
				rowOrdersRow["ShippedDate"] = shippedDate;
				rowOrdersRow["ShipVia"] = shipVia;
				rowOrdersRow["Freight"] = freight;
				rowOrdersRow["ShipName"] = shipName;
				rowOrdersRow["ShipAddress"] = shipAddress;
				rowOrdersRow["ShipCity"] = shipCity;
				rowOrdersRow["ShipRegion"] = shipRegion;
				rowOrdersRow["ShipPostalCode"] = shipPostalCode;
				rowOrdersRow["ShipCountry"] = shipCountry;
				this.Rows.Add(rowOrdersRow);
				return rowOrdersRow;
			}
			
			public OrdersRow FindByOrderID(int orderID)
			{
				return ((OrdersRow)(this.Rows.Find(new object[] {orderID})));
			}
			
			public IEnumerator GetEnumerator()
			{
				return this.Rows.GetEnumerator();
			}
			
			public override DataTable Clone()
			{
				OrdersDataTable cln = ((OrdersDataTable)(base.Clone()));
				cln.InitVars();
				return cln;
			}
			
			internal void InitVars()
			{
				_columnOrderID = this.Columns["OrderID"];
				_columnCustomerID = this.Columns["CustomerID"];
				_columnEmployeeID = this.Columns["EmployeeID"];
				_columnOrderDate = this.Columns["OrderDate"];
				_columnRequiredDate = this.Columns["RequiredDate"];
				_columnShippedDate = this.Columns["ShippedDate"];
				_columnShipVia = this.Columns["ShipVia"];
				_columnFreight = this.Columns["Freight"];
				_columnShipName = this.Columns["ShipName"];
				_columnShipAddress = this.Columns["ShipAddress"];
				_columnShipCity = this.Columns["ShipCity"];
				_columnShipRegion = this.Columns["ShipRegion"];
				_columnShipPostalCode = this.Columns["ShipPostalCode"];
				_columnShipCountry = this.Columns["ShipCountry"];
			}
			
			public void InitClass()
			{
				_columnOrderID = new DataColumn("OrderID", typeof(int), "", MappingType.Element);
				_columnOrderID.AllowDBNull = false;
				_columnOrderID.Caption = "Order ID";
				_columnOrderID.Unique = true;
				_columnOrderID.DefaultValue = Convert.DBNull;
				_columnOrderID.ExtendedProperties.Add("IsKey", "true");
				_columnOrderID.ExtendedProperties.Add("ReadOnly", "false");
				_columnOrderID.ExtendedProperties.Add("Description", "Order ID");
				_columnOrderID.ExtendedProperties.Add("Decimals", "0");
				_columnOrderID.ExtendedProperties.Add("AllowDBNulls", "false");
				this.Columns.Add(_columnOrderID);
				
				_columnCustomerID = new DataColumn("CustomerID", typeof(string), "", MappingType.Element);
				_columnCustomerID.AllowDBNull = true;
				_columnCustomerID.Caption = "Customer ID";
				_columnCustomerID.Unique = false;
				_columnCustomerID.DefaultValue = Convert.DBNull;
				_columnCustomerID.ExtendedProperties.Add("IsKey", "false");
				_columnCustomerID.ExtendedProperties.Add("ReadOnly", "false");
				_columnCustomerID.ExtendedProperties.Add("Description", "Customer ID");
				_columnCustomerID.ExtendedProperties.Add("Decimals", "0");
				_columnCustomerID.ExtendedProperties.Add("AllowDBNulls", "true");
				this.Columns.Add(_columnCustomerID);
				
				_columnEmployeeID = new DataColumn("EmployeeID", typeof(int), "", MappingType.Element);
				_columnEmployeeID.AllowDBNull = true;
				_columnEmployeeID.Caption = "Employee ID";
				_columnEmployeeID.Unique = false;
				_columnEmployeeID.DefaultValue = Convert.DBNull;
				_columnEmployeeID.ExtendedProperties.Add("IsKey", "false");
				_columnEmployeeID.ExtendedProperties.Add("ReadOnly", "false");
				_columnEmployeeID.ExtendedProperties.Add("Description", "Employee ID");
				_columnEmployeeID.ExtendedProperties.Add("Decimals", "0");
				_columnEmployeeID.ExtendedProperties.Add("AllowDBNulls", "true");
				this.Columns.Add(_columnEmployeeID);
				
				_columnOrderDate = new DataColumn("OrderDate", typeof(DateTime), "", MappingType.Element);
				_columnOrderDate.AllowDBNull = true;
				_columnOrderDate.Caption = "Order Date";
				_columnOrderDate.Unique = false;
				_columnOrderDate.DefaultValue = Convert.DBNull;
				_columnOrderDate.ExtendedProperties.Add("IsKey", "false");
				_columnOrderDate.ExtendedProperties.Add("ReadOnly", "false");
				_columnOrderDate.ExtendedProperties.Add("Description", "Order Date");
				_columnOrderDate.ExtendedProperties.Add("Decimals", "0");
				_columnOrderDate.ExtendedProperties.Add("AllowDBNulls", "true");
				this.Columns.Add(_columnOrderDate);
				
				_columnRequiredDate = new DataColumn("RequiredDate", typeof(DateTime), "", MappingType.Element);
				_columnRequiredDate.AllowDBNull = true;
				_columnRequiredDate.Caption = "Required Date";
				_columnRequiredDate.Unique = false;
				_columnRequiredDate.DefaultValue = Convert.DBNull;
				_columnRequiredDate.ExtendedProperties.Add("IsKey", "false");
				_columnRequiredDate.ExtendedProperties.Add("ReadOnly", "false");
				_columnRequiredDate.ExtendedProperties.Add("Description", "Required Date");
				_columnRequiredDate.ExtendedProperties.Add("Decimals", "0");
				_columnRequiredDate.ExtendedProperties.Add("AllowDBNulls", "true");
				this.Columns.Add(_columnRequiredDate);
				
				_columnShippedDate = new DataColumn("ShippedDate", typeof(DateTime), "", MappingType.Element);
				_columnShippedDate.AllowDBNull = true;
				_columnShippedDate.Caption = "Shipped Date";
				_columnShippedDate.Unique = false;
				_columnShippedDate.DefaultValue = Convert.DBNull;
				_columnShippedDate.ExtendedProperties.Add("IsKey", "false");
				_columnShippedDate.ExtendedProperties.Add("ReadOnly", "false");
				_columnShippedDate.ExtendedProperties.Add("Description", "Shipped Date");
				_columnShippedDate.ExtendedProperties.Add("Decimals", "0");
				_columnShippedDate.ExtendedProperties.Add("AllowDBNulls", "true");
				this.Columns.Add(_columnShippedDate);
				
				_columnShipVia = new DataColumn("ShipVia", typeof(int), "", MappingType.Element);
				_columnShipVia.AllowDBNull = true;
				_columnShipVia.Caption = "Ship Via";
				_columnShipVia.Unique = false;
				_columnShipVia.DefaultValue = Convert.DBNull;
				_columnShipVia.ExtendedProperties.Add("IsKey", "false");
				_columnShipVia.ExtendedProperties.Add("ReadOnly", "false");
				_columnShipVia.ExtendedProperties.Add("Description", "Ship Via");
				_columnShipVia.ExtendedProperties.Add("Decimals", "0");
				_columnShipVia.ExtendedProperties.Add("AllowDBNulls", "true");
				this.Columns.Add(_columnShipVia);
				
				_columnFreight = new DataColumn("Freight", typeof(decimal), "", MappingType.Element);
				_columnFreight.AllowDBNull = true;
				_columnFreight.Caption = "Freight";
				_columnFreight.Unique = false;
				_columnFreight.DefaultValue = Convert.DBNull;
				_columnFreight.ExtendedProperties.Add("IsKey", "false");
				_columnFreight.ExtendedProperties.Add("ReadOnly", "false");
				_columnFreight.ExtendedProperties.Add("Description", "Freight");
				_columnFreight.ExtendedProperties.Add("Decimals", "0");
				_columnFreight.ExtendedProperties.Add("AllowDBNulls", "true");
				this.Columns.Add(_columnFreight);
				
				_columnShipName = new DataColumn("ShipName", typeof(string), "", MappingType.Element);
				_columnShipName.AllowDBNull = true;
				_columnShipName.Caption = "Ship Name";
				_columnShipName.MaxLength = 40;
				_columnShipName.Unique = false;
				_columnShipName.DefaultValue = Convert.DBNull;
				_columnShipName.ExtendedProperties.Add("IsKey", "false");
				_columnShipName.ExtendedProperties.Add("ReadOnly", "false");
				_columnShipName.ExtendedProperties.Add("Description", "Ship Name");
				_columnShipName.ExtendedProperties.Add("Length", "40");
				_columnShipName.ExtendedProperties.Add("Decimals", "0");
				_columnShipName.ExtendedProperties.Add("AllowDBNulls", "true");
				this.Columns.Add(_columnShipName);
				
				_columnShipAddress = new DataColumn("ShipAddress", typeof(string), "", MappingType.Element);
				_columnShipAddress.AllowDBNull = true;
				_columnShipAddress.Caption = "Ship Address";
				_columnShipAddress.MaxLength = 60;
				_columnShipAddress.Unique = false;
				_columnShipAddress.DefaultValue = Convert.DBNull;
				_columnShipAddress.ExtendedProperties.Add("IsKey", "false");
				_columnShipAddress.ExtendedProperties.Add("ReadOnly", "false");
				_columnShipAddress.ExtendedProperties.Add("Description", "Ship Address");
				_columnShipAddress.ExtendedProperties.Add("Length", "60");
				_columnShipAddress.ExtendedProperties.Add("Decimals", "0");
				_columnShipAddress.ExtendedProperties.Add("AllowDBNulls", "true");
				this.Columns.Add(_columnShipAddress);
				
				_columnShipCity = new DataColumn("ShipCity", typeof(string), "", MappingType.Element);
				_columnShipCity.AllowDBNull = true;
				_columnShipCity.Caption = "Ship City";
				_columnShipCity.MaxLength = 15;
				_columnShipCity.Unique = false;
				_columnShipCity.DefaultValue = Convert.DBNull;
				_columnShipCity.ExtendedProperties.Add("IsKey", "false");
				_columnShipCity.ExtendedProperties.Add("ReadOnly", "false");
				_columnShipCity.ExtendedProperties.Add("Description", "Ship City");
				_columnShipCity.ExtendedProperties.Add("Length", "15");
				_columnShipCity.ExtendedProperties.Add("Decimals", "0");
				_columnShipCity.ExtendedProperties.Add("AllowDBNulls", "true");
				this.Columns.Add(_columnShipCity);
				
				_columnShipRegion = new DataColumn("ShipRegion", typeof(string), "", MappingType.Element);
				_columnShipRegion.AllowDBNull = true;
				_columnShipRegion.Caption = "Ship Region";
				_columnShipRegion.MaxLength = 15;
				_columnShipRegion.Unique = false;
				_columnShipRegion.DefaultValue = Convert.DBNull;
				_columnShipRegion.ExtendedProperties.Add("IsKey", "false");
				_columnShipRegion.ExtendedProperties.Add("ReadOnly", "false");
				_columnShipRegion.ExtendedProperties.Add("Description", "Ship Region");
				_columnShipRegion.ExtendedProperties.Add("Length", "15");
				_columnShipRegion.ExtendedProperties.Add("Decimals", "0");
				_columnShipRegion.ExtendedProperties.Add("AllowDBNulls", "true");
				this.Columns.Add(_columnShipRegion);
				
				_columnShipPostalCode = new DataColumn("ShipPostalCode", typeof(string), "", MappingType.Element);
				_columnShipPostalCode.AllowDBNull = true;
				_columnShipPostalCode.Caption = "Ship Postal Code";
				_columnShipPostalCode.MaxLength = 10;
				_columnShipPostalCode.Unique = false;
				_columnShipPostalCode.DefaultValue = Convert.DBNull;
				_columnShipPostalCode.ExtendedProperties.Add("IsKey", "false");
				_columnShipPostalCode.ExtendedProperties.Add("ReadOnly", "false");
				_columnShipPostalCode.ExtendedProperties.Add("Description", "Ship Postal Code");
				_columnShipPostalCode.ExtendedProperties.Add("Length", "10");
				_columnShipPostalCode.ExtendedProperties.Add("Decimals", "0");
				_columnShipPostalCode.ExtendedProperties.Add("AllowDBNulls", "true");
				this.Columns.Add(_columnShipPostalCode);
				
				_columnShipCountry = new DataColumn("ShipCountry", typeof(string), "", MappingType.Element);
				_columnShipCountry.AllowDBNull = true;
				_columnShipCountry.Caption = "Ship Country";
				_columnShipCountry.MaxLength = 15;
				_columnShipCountry.Unique = false;
				_columnShipCountry.DefaultValue = Convert.DBNull;
				_columnShipCountry.ExtendedProperties.Add("IsKey", "false");
				_columnShipCountry.ExtendedProperties.Add("ReadOnly", "false");
				_columnShipCountry.ExtendedProperties.Add("Description", "Ship Country");
				_columnShipCountry.ExtendedProperties.Add("Length", "15");
				_columnShipCountry.ExtendedProperties.Add("Decimals", "0");
				_columnShipCountry.ExtendedProperties.Add("AllowDBNulls", "true");
				this.Columns.Add(_columnShipCountry);
				
				this.PrimaryKey = new DataColumn[] {_columnOrderID};
			}
			
			public OrdersRow NewOrdersRow()
			{
				OrdersRow rowOrdersRow = ((OrdersRow)(this.NewRow()));
				return rowOrdersRow;
			}
			
			protected override DataRow NewRowFromBuilder(DataRowBuilder builder)
			{
				return new OrdersRow(builder);
			}
			
			protected override Type GetRowType()
			{
				return typeof(OrdersRow);
			}
			
			protected override void OnRowChanged(DataRowChangeEventArgs e)
			{
				base.OnRowChanged(e);
				if (this.OrdersRowChanged != null)
				{
					this.OrdersRowChanged(this, new OrdersRowChangeEventArgs(((OrdersRow)(e.Row)), e.Action));
				}
			}
			
			protected override void OnRowChanging(DataRowChangeEventArgs e)
			{
				base.OnRowChanging(e);
				if (this.OrdersRowChanging != null)
				{
					this.OrdersRowChanging(this, new OrdersRowChangeEventArgs(((OrdersRow)(e.Row)), e.Action));
				}
			}
			
			protected override void OnRowDeleted(DataRowChangeEventArgs e)
			{
				base.OnRowDeleted(e);
				if (this.OrdersRowDeleted != null)
				{
					this.OrdersRowDeleted(this, new OrdersRowChangeEventArgs(((OrdersRow)(e.Row)), e.Action));
				}
			}
			
			protected override void OnRowDeleting(DataRowChangeEventArgs e)
			{
				base.OnRowDeleting(e);
				if (this.OrdersRowDeleting != null)
				{
					this.OrdersRowDeleting(this, new OrdersRowChangeEventArgs(((OrdersRow)(e.Row)), e.Action));
				}
			}
			
			public void RemoveOrdersRow(OrdersRow row)
			{
				this.Rows.Remove(row);
			}
		}
		
		public class OrdersRow: DataRow
		{
			private OrdersDataTable _tableOrders;
			
			internal OrdersRow(DataRowBuilder rb): base(rb)
			{
				_tableOrders = ((OrdersDataTable)(this.Table));
			}
			
			/// <summary>
			/// Gets or sets the value of OrderID property
			/// </summary>
			public int OrderID
			{
				get
				{
					try
					{
						return ((int)(this[_tableOrders.OrderIDColumn]));
					}
					catch (InvalidCastException exception)
					{
						throw new StrongTypingException("Cannot get value OrderID because it is DBNull.", exception);
					}
				}
				set
				{
					this[_tableOrders.OrderIDColumn] = value;
				}
			}
			
			public bool IsOrderIDNull()
			{
				return this.IsNull(_tableOrders.OrderIDColumn);
			}
			
			public void SetOrderIDNull()
			{
				this[_tableOrders.OrderIDColumn] = Convert.DBNull;
			}
			
			/// <summary>
			/// Gets or sets the value of CustomerID property
			/// </summary>
			public string CustomerID
			{
				get
				{
					try
					{
						return ((string)(this[_tableOrders.CustomerIDColumn]));
					}
					catch (InvalidCastException exception)
					{
						throw new StrongTypingException("Cannot get value CustomerID because it is DBNull.", exception);
					}
				}
				set
				{
					this[_tableOrders.CustomerIDColumn] = value;
				}
			}
			
			public bool IsCustomerIDNull()
			{
				return this.IsNull(_tableOrders.CustomerIDColumn);
			}
			
			public void SetCustomerIDNull()
			{
				this[_tableOrders.CustomerIDColumn] = Convert.DBNull;
			}
			
			/// <summary>
			/// Gets or sets the value of EmployeeID property
			/// </summary>
			public int EmployeeID
			{
				get
				{
					try
					{
						return ((int)(this[_tableOrders.EmployeeIDColumn]));
					}
					catch (InvalidCastException exception)
					{
						throw new StrongTypingException("Cannot get value EmployeeID because it is DBNull.", exception);
					}
				}
				set
				{
					this[_tableOrders.EmployeeIDColumn] = value;
				}
			}
			
			public bool IsEmployeeIDNull()
			{
				return this.IsNull(_tableOrders.EmployeeIDColumn);
			}
			
			public void SetEmployeeIDNull()
			{
				this[_tableOrders.EmployeeIDColumn] = Convert.DBNull;
			}
			
			/// <summary>
			/// Gets or sets the value of OrderDate property
			/// </summary>
			public DateTime OrderDate
			{
				get
				{
					try
					{
						return ((DateTime)(this[_tableOrders.OrderDateColumn]));
					}
					catch (InvalidCastException exception)
					{
						throw new StrongTypingException("Cannot get value OrderDate because it is DBNull.", exception);
					}
				}
				set
				{
					this[_tableOrders.OrderDateColumn] = value;
				}
			}
			
			public bool IsOrderDateNull()
			{
				return this.IsNull(_tableOrders.OrderDateColumn);
			}
			
			public void SetOrderDateNull()
			{
				this[_tableOrders.OrderDateColumn] = Convert.DBNull;
			}
			
			/// <summary>
			/// Gets or sets the value of RequiredDate property
			/// </summary>
			public DateTime RequiredDate
			{
				get
				{
					try
					{
						return ((DateTime)(this[_tableOrders.RequiredDateColumn]));
					}
					catch (InvalidCastException exception)
					{
						throw new StrongTypingException("Cannot get value RequiredDate because it is DBNull.", exception);
					}
				}
				set
				{
					this[_tableOrders.RequiredDateColumn] = value;
				}
			}
			
			public bool IsRequiredDateNull()
			{
				return this.IsNull(_tableOrders.RequiredDateColumn);
			}
			
			public void SetRequiredDateNull()
			{
				this[_tableOrders.RequiredDateColumn] = Convert.DBNull;
			}
			
			/// <summary>
			/// Gets or sets the value of ShippedDate property
			/// </summary>
			public DateTime ShippedDate
			{
				get
				{
					try
					{
						return ((DateTime)(this[_tableOrders.ShippedDateColumn]));
					}
					catch (InvalidCastException exception)
					{
						throw new StrongTypingException("Cannot get value ShippedDate because it is DBNull.", exception);
					}
				}
				set
				{
					this[_tableOrders.ShippedDateColumn] = value;
				}
			}
			
			public bool IsShippedDateNull()
			{
				return this.IsNull(_tableOrders.ShippedDateColumn);
			}
			
			public void SetShippedDateNull()
			{
				this[_tableOrders.ShippedDateColumn] = Convert.DBNull;
			}
			
			/// <summary>
			/// Gets or sets the value of ShipVia property
			/// </summary>
			public int ShipVia
			{
				get
				{
					try
					{
						return ((int)(this[_tableOrders.ShipViaColumn]));
					}
					catch (InvalidCastException exception)
					{
						throw new StrongTypingException("Cannot get value ShipVia because it is DBNull.", exception);
					}
				}
				set
				{
					this[_tableOrders.ShipViaColumn] = value;
				}
			}
			
			public bool IsShipViaNull()
			{
				return this.IsNull(_tableOrders.ShipViaColumn);
			}
			
			public void SetShipViaNull()
			{
				this[_tableOrders.ShipViaColumn] = Convert.DBNull;
			}
			
			/// <summary>
			/// Gets or sets the value of Freight property
			/// </summary>
			public decimal Freight
			{
				get
				{
					try
					{
						return ((decimal)(this[_tableOrders.FreightColumn]));
					}
					catch (InvalidCastException exception)
					{
						throw new StrongTypingException("Cannot get value Freight because it is DBNull.", exception);
					}
				}
				set
				{
					this[_tableOrders.FreightColumn] = value;
				}
			}
			
			public bool IsFreightNull()
			{
				return this.IsNull(_tableOrders.FreightColumn);
			}
			
			public void SetFreightNull()
			{
				this[_tableOrders.FreightColumn] = Convert.DBNull;
			}
			
			/// <summary>
			/// Gets or sets the value of ShipName property
			/// </summary>
			public string ShipName
			{
				get
				{
					try
					{
						return ((string)(this[_tableOrders.ShipNameColumn]));
					}
					catch (InvalidCastException exception)
					{
						throw new StrongTypingException("Cannot get value ShipName because it is DBNull.", exception);
					}
				}
				set
				{
					this[_tableOrders.ShipNameColumn] = value;
				}
			}
			
			public bool IsShipNameNull()
			{
				return this.IsNull(_tableOrders.ShipNameColumn);
			}
			
			public void SetShipNameNull()
			{
				this[_tableOrders.ShipNameColumn] = Convert.DBNull;
			}
			
			/// <summary>
			/// Gets or sets the value of ShipAddress property
			/// </summary>
			public string ShipAddress
			{
				get
				{
					try
					{
						return ((string)(this[_tableOrders.ShipAddressColumn]));
					}
					catch (InvalidCastException exception)
					{
						throw new StrongTypingException("Cannot get value ShipAddress because it is DBNull.", exception);
					}
				}
				set
				{
					this[_tableOrders.ShipAddressColumn] = value;
				}
			}
			
			public bool IsShipAddressNull()
			{
				return this.IsNull(_tableOrders.ShipAddressColumn);
			}
			
			public void SetShipAddressNull()
			{
				this[_tableOrders.ShipAddressColumn] = Convert.DBNull;
			}
			
			/// <summary>
			/// Gets or sets the value of ShipCity property
			/// </summary>
			public string ShipCity
			{
				get
				{
					try
					{
						return ((string)(this[_tableOrders.ShipCityColumn]));
					}
					catch (InvalidCastException exception)
					{
						throw new StrongTypingException("Cannot get value ShipCity because it is DBNull.", exception);
					}
				}
				set
				{
					this[_tableOrders.ShipCityColumn] = value;
				}
			}
			
			public bool IsShipCityNull()
			{
				return this.IsNull(_tableOrders.ShipCityColumn);
			}
			
			public void SetShipCityNull()
			{
				this[_tableOrders.ShipCityColumn] = Convert.DBNull;
			}
			
			/// <summary>
			/// Gets or sets the value of ShipRegion property
			/// </summary>
			public string ShipRegion
			{
				get
				{
					try
					{
						return ((string)(this[_tableOrders.ShipRegionColumn]));
					}
					catch (InvalidCastException exception)
					{
						throw new StrongTypingException("Cannot get value ShipRegion because it is DBNull.", exception);
					}
				}
				set
				{
					this[_tableOrders.ShipRegionColumn] = value;
				}
			}
			
			public bool IsShipRegionNull()
			{
				return this.IsNull(_tableOrders.ShipRegionColumn);
			}
			
			public void SetShipRegionNull()
			{
				this[_tableOrders.ShipRegionColumn] = Convert.DBNull;
			}
			
			/// <summary>
			/// Gets or sets the value of ShipPostalCode property
			/// </summary>
			public string ShipPostalCode
			{
				get
				{
					try
					{
						return ((string)(this[_tableOrders.ShipPostalCodeColumn]));
					}
					catch (InvalidCastException exception)
					{
						throw new StrongTypingException("Cannot get value ShipPostalCode because it is DBNull.", exception);
					}
				}
				set
				{
					this[_tableOrders.ShipPostalCodeColumn] = value;
				}
			}
			
			public bool IsShipPostalCodeNull()
			{
				return this.IsNull(_tableOrders.ShipPostalCodeColumn);
			}
			
			public void SetShipPostalCodeNull()
			{
				this[_tableOrders.ShipPostalCodeColumn] = Convert.DBNull;
			}
			
			/// <summary>
			/// Gets or sets the value of ShipCountry property
			/// </summary>
			public string ShipCountry
			{
				get
				{
					try
					{
						return ((string)(this[_tableOrders.ShipCountryColumn]));
					}
					catch (InvalidCastException exception)
					{
						throw new StrongTypingException("Cannot get value ShipCountry because it is DBNull.", exception);
					}
				}
				set
				{
					this[_tableOrders.ShipCountryColumn] = value;
				}
			}
			
			public bool IsShipCountryNull()
			{
				return this.IsNull(_tableOrders.ShipCountryColumn);
			}
			
			public void SetShipCountryNull()
			{
				this[_tableOrders.ShipCountryColumn] = Convert.DBNull;
			}
			
		}
		
		public class OrdersRowChangeEventArgs: EventArgs
		{
			private OrdersRow _eventRow;
			private System.Data.DataRowAction _eventAction;
			
			public OrdersRowChangeEventArgs(OrdersRow row, DataRowAction action)
			{
				_eventRow = row;
				_eventAction = action;
			}
			
			public OrdersRow Row
			{
				get
				{
					return _eventRow;
				}
			}
			
			public DataRowAction Action
			{
				get
				{
					return _eventAction;
				}
			}
		}
	}
	#endregion
	
	#region OrdersDataAdapter
	public class OrdersDataAdapter: MarshalByRefObject, IDataAdapter
	{
		#region Member Variables
		private IDbConnection _connection;
		private IDbTransaction _transaction;
		private IDbCommand _command;
		private IDataReader _reader;
		private int _connectionTimeout = 30;
		private int _commandTimeout = 30;
		private string _connectionStringKey;
		private bool _autoCloseConnection = true;
		private bool _autoCommitTransaction = true;
		private bool _convertEmptyValuesToDBNull = true;
		//private IDataParameter[] _fillDataParameters;
		#endregion
		
		#region Constructors
		public OrdersDataAdapter(string connectionStringKey)
		{
			_connectionStringKey = connectionStringKey;
		}
		
		public OrdersDataAdapter(IDbConnection connection)
		{
			this.Connection = connection;
		}
		
		public OrdersDataAdapter(IDbTransaction transaction)
		{
			this.Transaction = transaction;
		}
		#endregion
		
		#region Properties
		public IDbConnection Connection
		{
			get
			{
				if (_connection == null)
				{
					_connection = new SqlConnection();
					_connection.ConnectionString = System.Configuration.ConfigurationSettings.AppSettings[this.ConnectionStringKey];;
					//_connection.ConnectionTimeout = this.ConnectionTimeout;
				}
				return _connection;
			}
			set
			{
				_connection = value;
				// if the connection is passed in then it should be up to the owner to close the connection.
				_autoCloseConnection = false;
			}
		}
		
		public IDbTransaction Transaction
		{
			get	{return _transaction;}
			set
			{
				_transaction = value;
				_connection = _transaction.Connection;
				// if the connection is passed in then it should be up to the owner to close the connection.
				_autoCloseConnection = false;
				// if the transaction is passed in then it should be up to the owner of the transaction to commit.
				_autoCommitTransaction = false;
			}
		}
		
		public bool AutoCloseConnection
		{
			get {return _autoCloseConnection;}
			set {_autoCloseConnection = value;}
		}
		
		public bool AutoCommitTransaction
		{
			get {return _autoCommitTransaction;}
			set {_autoCommitTransaction = value;}
		}
		
		public bool ConvertEmptyValuesToDBNull
		{
			get {return _convertEmptyValuesToDBNull;}
			set {_convertEmptyValuesToDBNull = value;}
		}
		
		public string ConnectionStringKey
		{
			get {return _connectionStringKey;}
		}
		
		public int ConnectionTimeout
		{
			get	{return _connectionTimeout;}
			set	{_connectionTimeout = value;}
		}
		
		public int CommandTimeout
		{
			get	{return _commandTimeout;}
			set	{_commandTimeout = value;}
		}
		
		public MissingMappingAction MissingMappingAction
		{
			get	{return MissingMappingAction.Passthrough;}
			set {}
		}
		
		public MissingSchemaAction MissingSchemaAction
		{
			get	{return MissingSchemaAction.Ignore;}
			set	{}
		}
		
		public ITableMappingCollection TableMappings
		{
			get
			{
				System.Data.Common.DataTableMappingCollection tableMaps;
				tableMaps = new System.Data.Common.DataTableMappingCollection();
				return tableMaps;
			}
		}
		#endregion
		
		#region Helper Methods
		private IDbCommand GetCommand()
		{
			if (this.Connection != null)
			{
				_command = this.Connection.CreateCommand();
				_command.CommandTimeout = this.CommandTimeout;
				_command.CommandType = CommandType.Text;
				_command.Connection = this.Connection;
				if (_transaction != null) _command.Transaction = _transaction;
				
				return _command;
			}
			else
			{
				throw new InvalidOperationException("You must have a valid Connection object before calling GetCommand.");
			}
		}
		
		private void OpenConnection()
		{
			if (this.Connection != null)
			{
				if (this.Connection.State == ConnectionState.Closed) _connection.Open();
			}
			else
			{
				throw new InvalidOperationException("You must have a valid Connection object before calling GetCommand.");
			}
		}

		private void Cleanup()
		{
			try
			{
				if (_reader != null)
				{
					if (!_reader.IsClosed) _reader.Close();
					_reader.Dispose();
					_reader = null;
				}
				
				if (_command != null)
				{
					_command.Dispose();
					_command = null;
				}
				
				if (_connection != null && this.AutoCloseConnection == true)
				{
					if (_connection.State == ConnectionState.Open) _connection.Close();
					_connection.Dispose();
					_connection = null;
				}
			}
			catch {}
		}
		#endregion
		
		#region CreateParameter
		public IDbDataParameter CreateParameter(string name, DbType type, object value)
		{
			IDbDataParameter prm = _command.CreateParameter();
			prm.Direction = ParameterDirection.Input;
			prm.ParameterName = name;
			prm.DbType = type;
			prm.Value = this.PrepareParameterValue(value);
			
			return prm;
		}
		
		public IDbDataParameter CreateParameter(string name, DbType type, object value, int size)
		{
			IDbDataParameter prm = _command.CreateParameter();
			prm.Direction = ParameterDirection.Input;
			prm.ParameterName = name;
			prm.DbType = type;
			prm.Size = size;
			prm.Value = this.PrepareParameterValue(value);
			
			return prm;
		}
		
		public IDbDataParameter CreateParameter(string name, DbType type, object value, ParameterDirection direction)
		{
			IDbDataParameter prm = _command.CreateParameter();
			prm.Direction = direction;
			prm.ParameterName = name;
			prm.DbType = type;
			prm.Value = this.PrepareParameterValue(value);
			
			return prm;
		}
		
		public IDbDataParameter CreateParameter(string name, DbType type, object value, int size, ParameterDirection direction)
		{
			IDbDataParameter prm = _command.CreateParameter();
			prm.Direction = direction;
			prm.ParameterName = name;
			prm.DbType = type;
			prm.Size = size;
			prm.Value = this.PrepareParameterValue(value);
			
			return prm;
		}
		
		private object PrepareParameterValue(object value)
		{
			return PrepareParameterValue(value, false);
		}
		
		private object PrepareParameterValue(object value, bool convertZeroToDBNull)
		{
			if (!_convertEmptyValuesToDBNull) return value;
			
			switch (value.GetType().ToString())
			{
				case "System.String":
					if (Convert.ToString(value) == String.Empty)
					{
						return DBNull.Value;
					}
					else
					{
						return value;
					}
				case "System.Guid":
					if (new Guid(Convert.ToString(value)) == Guid.Empty)
					{
						return DBNull.Value;
					}
					else
					{
						return value;
					}
				case "System.DateTime":
					if (Convert.ToDateTime(value) == DateTime.MinValue)
					{
						return DBNull.Value;
					}
					else
					{
						return value;
					}
				case "System.Int16":
					if (Convert.ToInt16(value) == 0)
					{
						if (convertZeroToDBNull)
						{
							return DBNull.Value;
						}
						else
						{
							return value;
						}
					}
					else
					{
						return value;
					}
				case "System.Int32":
					if (Convert.ToInt32(value) == 0)
					{
						if (convertZeroToDBNull)
						{
							return DBNull.Value;
						}
						else
						{
							return value;
						}
					}
					else
					{
						return value;
					}
				case "System.Int64":
					if (Convert.ToInt64(value) == 0)
					{
						if (convertZeroToDBNull)
						{
							return DBNull.Value;
						}
						else
						{
							return value;
						}
					}
					else
					{
						return value;
					}
				case "System.Single":
					if (Convert.ToSingle(value) == 0)
					{
						if (convertZeroToDBNull)
						{
							return DBNull.Value;
						}
						else
						{
							return value;
						}
					}
					else
					{
						return value;
					}
				case "System.Double":
					if (Convert.ToDouble(value) == 0)
					{
						if (convertZeroToDBNull)
						{
							return DBNull.Value;
						}
						else
						{
							return value;
						}
					}
					else
					{
						return value;
					}
				case "System.Decimal":
					if (Convert.ToDecimal(value) == 0)
					{
						if (convertZeroToDBNull)
						{
							return DBNull.Value;
						}
						else
						{
							return value;
						}
					}
					else
					{
						return value;
					}
				default:
					return value;
			}
		}
		#endregion AddParameter
		
		#region Fill Methods
		public DataTable[] FillSchema(DataSet dataSet, SchemaType schemaType)
		{
			DataTable[] dataTables;
			dataTables = new DataTable[dataSet.Tables.Count];
			dataSet.Tables.CopyTo(dataTables, dataSet.Tables.Count);
			return dataTables;
		}
		
		public int Fill(OrdersDataSet dataSet, IDataRecord dataRecord)
		{
			return Fill(dataSet, ((int)(dataRecord["OrderID"])));
		}
		
		public int Fill(OrdersDataSet dataSet, DataRow dataRecord)
		{
			return Fill(dataSet, ((int)(dataRecord["OrderID"])));
		}
		
		public int Fill(OrdersDataSet dataSet, int orderID)
		{
			try
			{
				_command = this.GetCommand();
				_command.CommandText = @"
					SELECT
						[OrderID],
						[CustomerID],
						[EmployeeID],
						[OrderDate],
						[RequiredDate],
						[ShippedDate],
						[ShipVia],
						[Freight],
						[ShipName],
						[ShipAddress],
						[ShipCity],
						[ShipRegion],
						[ShipPostalCode],
						[ShipCountry]
					FROM
						[Orders]
					WHERE
						[OrderID] = @OrderID
					";
				_command.Parameters.Add(this.CreateParameter("@OrderID", DbType.Int32, orderID));
				this.OpenConnection();
				_reader = _command.ExecuteReader(CommandBehavior.CloseConnection | CommandBehavior.SingleResult | CommandBehavior.SingleRow);
				if (_reader.Read())
				{
					OrdersDataSet.OrdersRow row = dataSet.Orders.NewOrdersRow();
					this.PopulateOrdersDataRow(_reader, row);
					dataSet.Orders.AddOrdersRow(row);
					dataSet.AcceptChanges();
					
					return 1;
				}
				else
				{
					throw new OrdersNotFoundException();
				}
			}
			catch (Exception e)
			{
				System.Diagnostics.Debug.WriteLine(e.ToString());
				return 0;
			}
			finally
			{
				this.Cleanup();
			}
		}
		
		private void PopulateOrdersDataRow(IDataReader reader, OrdersDataSet.OrdersRow row)
		{
			if (!reader.IsDBNull(0)) row.OrderID = reader.GetInt32(0);
			if (!reader.IsDBNull(1)) row.CustomerID = reader.GetString(1);
			if (!reader.IsDBNull(2)) row.EmployeeID = reader.GetInt32(2);
			if (!reader.IsDBNull(3)) row.OrderDate = reader.GetDateTime(3);
			if (!reader.IsDBNull(4)) row.RequiredDate = reader.GetDateTime(4);
			if (!reader.IsDBNull(5)) row.ShippedDate = reader.GetDateTime(5);
			if (!reader.IsDBNull(6)) row.ShipVia = reader.GetInt32(6);
			if (!reader.IsDBNull(7)) row.Freight = reader.GetDecimal(7);
			if (!reader.IsDBNull(8)) row.ShipName = reader.GetString(8);
			if (!reader.IsDBNull(9)) row.ShipAddress = reader.GetString(9);
			if (!reader.IsDBNull(10)) row.ShipCity = reader.GetString(10);
			if (!reader.IsDBNull(11)) row.ShipRegion = reader.GetString(11);
			if (!reader.IsDBNull(12)) row.ShipPostalCode = reader.GetString(12);
			if (!reader.IsDBNull(13)) row.ShipCountry = reader.GetString(13);
		}
		
		public int Fill(DataSet dataSet)
		{
			OrdersDataSet pageDataSet = dataSet as OrdersDataSet;
			if (pageDataSet != null)
			{
				return this.Fill(pageDataSet);
			}
			else
			{
				throw new ApplicationException();
			}
		}
		
		public int Fill(OrdersDataSet dataSet)
		{
			try
			{
				int recordcount = 0;
				_command = this.GetCommand();
				_command.CommandText = @"
					SELECT
						[OrderID],
						[CustomerID],
						[EmployeeID],
						[OrderDate],
						[RequiredDate],
						[ShippedDate],
						[ShipVia],
						[Freight],
						[ShipName],
						[ShipAddress],
						[ShipCity],
						[ShipRegion],
						[ShipPostalCode],
						[ShipCountry]
					FROM
						[Orders]";
				this.OpenConnection();
				_reader = _command.ExecuteReader(CommandBehavior.CloseConnection | CommandBehavior.SingleResult);
				while (_reader.Read())
				{
					OrdersDataSet.OrdersRow row = dataSet.Orders.NewOrdersRow();
					this.PopulateOrdersDataRow(_reader, row);
					dataSet.Orders.AddOrdersRow(row);
					
					recordcount++;
				}
				dataSet.AcceptChanges();
				
				return recordcount;
			}
			catch (Exception e)
			{
				System.Diagnostics.Debug.WriteLine(e.ToString());
				return 0;
			}
			finally
			{
				this.Cleanup();
			}
		}
		
		public IDataParameter[] GetFillParameters()
		{
			// not sure if I should create a OrdersId parameter here or not.
			return null; //_fillDataParameters;
		}
		#endregion
		
		#region Update Methods
		public int Update(DataSet dataSet)
		{
			OrdersDataSet pageDataSet = dataSet as OrdersDataSet;
			if (pageDataSet != null)
			{
				return this.Update(pageDataSet);
			}
			else
			{
				throw new ApplicationException();
			}
		}
		
		public int Update(OrdersDataSet dataSet)
		{
			if (dataSet != null)
			{
				try
				{
					int updatedRowCount = 0;
					
					foreach(OrdersDataSet.OrdersRow row in dataSet.Orders)
					{
						switch (row.RowState)
						{
							case DataRowState.Added:
							{
								OnOrdersUpdating(new OrdersEventArgs(row, StatementType.Insert)) ;
								_command = this.GetCommand();
								_command.CommandText = @"
									INSERT INTO [Orders] (
										[OrderID],
										[CustomerID],
										[EmployeeID],
										[OrderDate],
										[RequiredDate],
										[ShippedDate],
										[ShipVia],
										[Freight],
										[ShipName],
										[ShipAddress],
										[ShipCity],
										[ShipRegion],
										[ShipPostalCode],
										[ShipCountry]
									) VALUES (
										@OrderID,
										@CustomerID,
										@EmployeeID,
										@OrderDate,
										@RequiredDate,
										@ShippedDate,
										@ShipVia,
										@Freight,
										@ShipName,
										@ShipAddress,
										@ShipCity,
										@ShipRegion,
										@ShipPostalCode,
										@ShipCountry
									)";
								_command.Parameters.Add(this.CreateParameter("@OrderID", DbType.Int32, row.IsOrderIDNull() ? (object)DBNull.Value : (object)row.OrderID));
								_command.Parameters.Add(this.CreateParameter("@CustomerID", DbType.StringFixedLength, row.IsCustomerIDNull() ? (object)DBNull.Value : (object)row.CustomerID));
								_command.Parameters.Add(this.CreateParameter("@EmployeeID", DbType.Int32, row.IsEmployeeIDNull() ? (object)DBNull.Value : (object)row.EmployeeID));
								_command.Parameters.Add(this.CreateParameter("@OrderDate", DbType.DateTime, row.IsOrderDateNull() ? (object)DBNull.Value : (object)row.OrderDate));
								_command.Parameters.Add(this.CreateParameter("@RequiredDate", DbType.DateTime, row.IsRequiredDateNull() ? (object)DBNull.Value : (object)row.RequiredDate));
								_command.Parameters.Add(this.CreateParameter("@ShippedDate", DbType.DateTime, row.IsShippedDateNull() ? (object)DBNull.Value : (object)row.ShippedDate));
								_command.Parameters.Add(this.CreateParameter("@ShipVia", DbType.Int32, row.IsShipViaNull() ? (object)DBNull.Value : (object)row.ShipVia));
								_command.Parameters.Add(this.CreateParameter("@Freight", DbType.Currency, row.IsFreightNull() ? (object)DBNull.Value : (object)row.Freight));
								_command.Parameters.Add(this.CreateParameter("@ShipName", DbType.String, row.IsShipNameNull() ? (object)DBNull.Value : (object)row.ShipName));
								_command.Parameters.Add(this.CreateParameter("@ShipAddress", DbType.String, row.IsShipAddressNull() ? (object)DBNull.Value : (object)row.ShipAddress));
								_command.Parameters.Add(this.CreateParameter("@ShipCity", DbType.String, row.IsShipCityNull() ? (object)DBNull.Value : (object)row.ShipCity));
								_command.Parameters.Add(this.CreateParameter("@ShipRegion", DbType.String, row.IsShipRegionNull() ? (object)DBNull.Value : (object)row.ShipRegion));
								_command.Parameters.Add(this.CreateParameter("@ShipPostalCode", DbType.String, row.IsShipPostalCodeNull() ? (object)DBNull.Value : (object)row.ShipPostalCode));
								_command.Parameters.Add(this.CreateParameter("@ShipCountry", DbType.String, row.IsShipCountryNull() ? (object)DBNull.Value : (object)row.ShipCountry));
								this.OpenConnection();
								_command.ExecuteNonQuery();
								OnOrdersUpdated(new OrdersEventArgs(row, StatementType.Insert)) ;
								
								updatedRowCount++;
								break;
							}
							case DataRowState.Modified:
							{
								OnOrdersUpdating(new OrdersEventArgs(row, StatementType.Update)) ;
								_command = this.GetCommand();
								_command.CommandText = @"
									UPDATE [Orders] SET
										[CustomerID] = @CustomerID,
										[EmployeeID] = @EmployeeID,
										[OrderDate] = @OrderDate,
										[RequiredDate] = @RequiredDate,
										[ShippedDate] = @ShippedDate,
										[ShipVia] = @ShipVia,
										[Freight] = @Freight,
										[ShipName] = @ShipName,
										[ShipAddress] = @ShipAddress,
										[ShipCity] = @ShipCity,
										[ShipRegion] = @ShipRegion,
										[ShipPostalCode] = @ShipPostalCode,
										[ShipCountry] = @ShipCountry
									WHERE
										[OrderID] = @OrderID
									";
								_command.Parameters.Add(this.CreateParameter("@OrderID", DbType.Int32, row.IsOrderIDNull() ? (object)DBNull.Value : (object)row.OrderID));
								_command.Parameters.Add(this.CreateParameter("@CustomerID", DbType.StringFixedLength, row.IsCustomerIDNull() ? (object)DBNull.Value : (object)row.CustomerID));
								_command.Parameters.Add(this.CreateParameter("@EmployeeID", DbType.Int32, row.IsEmployeeIDNull() ? (object)DBNull.Value : (object)row.EmployeeID));
								_command.Parameters.Add(this.CreateParameter("@OrderDate", DbType.DateTime, row.IsOrderDateNull() ? (object)DBNull.Value : (object)row.OrderDate));
								_command.Parameters.Add(this.CreateParameter("@RequiredDate", DbType.DateTime, row.IsRequiredDateNull() ? (object)DBNull.Value : (object)row.RequiredDate));
								_command.Parameters.Add(this.CreateParameter("@ShippedDate", DbType.DateTime, row.IsShippedDateNull() ? (object)DBNull.Value : (object)row.ShippedDate));
								_command.Parameters.Add(this.CreateParameter("@ShipVia", DbType.Int32, row.IsShipViaNull() ? (object)DBNull.Value : (object)row.ShipVia));
								_command.Parameters.Add(this.CreateParameter("@Freight", DbType.Currency, row.IsFreightNull() ? (object)DBNull.Value : (object)row.Freight));
								_command.Parameters.Add(this.CreateParameter("@ShipName", DbType.String, row.IsShipNameNull() ? (object)DBNull.Value : (object)row.ShipName));
								_command.Parameters.Add(this.CreateParameter("@ShipAddress", DbType.String, row.IsShipAddressNull() ? (object)DBNull.Value : (object)row.ShipAddress));
								_command.Parameters.Add(this.CreateParameter("@ShipCity", DbType.String, row.IsShipCityNull() ? (object)DBNull.Value : (object)row.ShipCity));
								_command.Parameters.Add(this.CreateParameter("@ShipRegion", DbType.String, row.IsShipRegionNull() ? (object)DBNull.Value : (object)row.ShipRegion));
								_command.Parameters.Add(this.CreateParameter("@ShipPostalCode", DbType.String, row.IsShipPostalCodeNull() ? (object)DBNull.Value : (object)row.ShipPostalCode));
								_command.Parameters.Add(this.CreateParameter("@ShipCountry", DbType.String, row.IsShipCountryNull() ? (object)DBNull.Value : (object)row.ShipCountry));
								this.OpenConnection();
								_command.ExecuteNonQuery();
								OnOrdersUpdated(new OrdersEventArgs(row, StatementType.Update)) ;
								
								updatedRowCount++;
								break;
							}
							case DataRowState.Deleted:
							{
								OnOrdersUpdating(new OrdersEventArgs(row, StatementType.Delete)) ;
								_command = this.GetCommand();
								_command.CommandText = @"
									DELETE FROM [Orders]
									WHERE
										[OrderID] = @OrderID
									";
								_command.Parameters.Add(this.CreateParameter("@OrderID", DbType.Int32, row[dataSet.Orders.OrderIDColumn, DataRowVersion.Original]));
								this.OpenConnection();
								_command.ExecuteNonQuery();
								OnOrdersUpdated(new OrdersEventArgs(row, StatementType.Delete)) ;
								
								updatedRowCount++;
								break;
							}
						}
					}
					dataSet.AcceptChanges();
					
					return updatedRowCount;
				}
				catch (Exception e)
				{
					System.Diagnostics.Debug.WriteLine(e.ToString());
					return 0;
				}
				finally
				{
					this.Cleanup();
				}
			}
			else
			{
				this.Cleanup();
				throw new ArgumentException("DataSet null");
			}
		}
		#endregion
		
		#region Events
		public delegate void OrdersUpdateEventHandler(object sender, OrdersEventArgs e);
		
		public event OrdersUpdateEventHandler OrdersUpdated;
		private void OnOrdersUpdated(OrdersEventArgs e)
		{
			if ((this.OrdersUpdated != null))
			{
				this.OrdersUpdated(this, e);
			}
		}
		
		public event OrdersUpdateEventHandler OrdersUpdating;
		private void OnOrdersUpdating(OrdersEventArgs e)
		{
			if ((this.OrdersUpdating != null))
			{
				this.OrdersUpdating(this, e);
			}
		}
		
		public class OrdersEventArgs : EventArgs
		{
			private StatementType _statementType;
			private OrdersDataSet.OrdersRow _dataRow;
			
			public OrdersEventArgs(OrdersDataSet.OrdersRow row, StatementType statementType)
			{
				_dataRow = row;
				_statementType = statementType;
			}
			
			public StatementType StatementType
			{
				get {return _statementType;}

			}
			
			public OrdersDataSet.OrdersRow Row
			{
				get {return _dataRow;}
				set	{_dataRow = value;}
			}
		}
		#endregion
		
		#region Custom Exceptions
		[Serializable()]
		public class OrdersNotFoundException: ApplicationException
		{
			public OrdersNotFoundException()
			{
			}
			
			public OrdersNotFoundException(string message) : base(message)
			{
			}
			
			public OrdersNotFoundException(string message, Exception inner): base(message, inner)
			{
			}
			
			protected OrdersNotFoundException(SerializationInfo info, StreamingContext context): base(info, context)
			{
			}
		}
		
		[Serializable()]
		public class ForeignKeyNotFoundException: ApplicationException
		{
			public ForeignKeyNotFoundException()
			{
			}
			
			public ForeignKeyNotFoundException(string message): base(message)
			{
			}
			
			public ForeignKeyNotFoundException(string message, Exception inner): base(message, inner)
			{
			}
			
			protected ForeignKeyNotFoundException(SerializationInfo info, StreamingContext context): base(info, context)
			{
			}
		}
		
		[Serializable()]
		public class OrdersDataLockedException: ApplicationException
		{
			public OrdersDataLockedException()
			{
			}
			
			public OrdersDataLockedException(string message): base(message)
			{
			}
			
			public OrdersDataLockedException(string message, Exception inner): base(message, inner)
			{
			}
			
			protected OrdersDataLockedException(SerializationInfo info, StreamingContext context): base(info, context)
			{
			}
		}

		[Serializable()]
		public class OrdersDataChangedException: ApplicationException
		{
			public OrdersDataChangedException()
			{
			}
			
			public OrdersDataChangedException(string message): base(message)
			{
			}
			
			public OrdersDataChangedException(string message, Exception inner): base(message, inner)
			{
			}
			
			protected OrdersDataChangedException(SerializationInfo info, StreamingContext context): base(info, context)
			{
			}
		}
		
		[Serializable()]
		public class OrdersDuplicateKeyException: ApplicationException
		{
			public OrdersDuplicateKeyException()
			{
			}
			
			public OrdersDuplicateKeyException(string message): base(message)
			{
			}
			
			public OrdersDuplicateKeyException(string message, Exception inner): base(message, inner)
			{
			}
			
			protected OrdersDuplicateKeyException(SerializationInfo info, StreamingContext context): base(info, context)
			{
			}
		}
		
		[Serializable()]
		public class OrdersDataDeletedException: ApplicationException
		{
			public OrdersDataDeletedException()
			{
			}
			
			public OrdersDataDeletedException(string message) : base(message)
			{
			}
			
			public OrdersDataDeletedException(string message, Exception inner): base(message, inner)
			{
			}
			
			protected OrdersDataDeletedException(SerializationInfo info, StreamingContext context): base(info, context)
			{
			}
		}
		#endregion
	}
	#endregion
}
