Click here to Skip to main content
15,891,473 members
Articles / Database Development / SQL Server

Silverlight 2 Database Updating

Rate me:
Please Sign up or sign in to vote.
4.08/5 (7 votes)
30 Aug 2008CPOL8 min read 150.6K   1.2K   45  
Perform database updates from Silverlight applications.
#pragma warning disable 1591
//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a tool.
//     Runtime Version:2.0.50727.1434
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

namespace DataWebService
{
	using System.Data.Linq;
	using System.Data.Linq.Mapping;
	using System.Data;
	using System.Collections.Generic;
	using System.Reflection;
	using System.Linq;
	using System.Linq.Expressions;
	using System.Runtime.Serialization;
	using System.ComponentModel;
	using System;
	
	
	[System.Data.Linq.Mapping.DatabaseAttribute(Name="NORTHWND")]
	public partial class NorthwindDataContext : System.Data.Linq.DataContext
	{
		
		private static System.Data.Linq.Mapping.MappingSource mappingSource = new AttributeMappingSource();
		
    #region Extensibility Method Definitions
    partial void OnCreated();
    partial void Inserttesttable(testtable instance);
    partial void Updatetesttable(testtable instance);
    partial void Deletetesttable(testtable instance);
    partial void InsertCustomer(Customer instance);
    partial void UpdateCustomer(Customer instance);
    partial void DeleteCustomer(Customer instance);
    #endregion
		
		public NorthwindDataContext() : 
				base(global::System.Configuration.ConfigurationManager.ConnectionStrings["NORTHWNDConnectionString"].ConnectionString, mappingSource)
		{
			OnCreated();
		}
		
		public NorthwindDataContext(string connection) : 
				base(connection, mappingSource)
		{
			OnCreated();
		}
		
		public NorthwindDataContext(System.Data.IDbConnection connection) : 
				base(connection, mappingSource)
		{
			OnCreated();
		}
		
		public NorthwindDataContext(string connection, System.Data.Linq.Mapping.MappingSource mappingSource) : 
				base(connection, mappingSource)
		{
			OnCreated();
		}
		
		public NorthwindDataContext(System.Data.IDbConnection connection, System.Data.Linq.Mapping.MappingSource mappingSource) : 
				base(connection, mappingSource)
		{
			OnCreated();
		}
		
		public System.Data.Linq.Table<testtable> testtables
		{
			get
			{
				return this.GetTable<testtable>();
			}
		}
		
		public System.Data.Linq.Table<Customer> Customers
		{
			get
			{
				return this.GetTable<Customer>();
			}
		}
	}
	
	[Table(Name="dbo.testtable")]
	[DataContract()]
	public partial class testtable : INotifyPropertyChanging, INotifyPropertyChanged
	{
		
		private static PropertyChangingEventArgs emptyChangingEventArgs = new PropertyChangingEventArgs(String.Empty);
		
		private int _id;
		
		private string _cchar;
		
		private string _nnvarchar;
		
		private System.Nullable<long> _bbigint;
		
		private System.Nullable<bool> _bbit;
		
		private System.Nullable<System.DateTime> _ddatetime;
		
		private System.Nullable<decimal> _ddecimal;
		
		private System.Nullable<double> _ffloat;
		
		private System.Nullable<int> _iint;
		
		private System.Nullable<decimal> _mmoney;
		
		private string _nntext;
		
		private System.Nullable<decimal> _nnumeric;
		
		private System.Nullable<float> _rreal;
		
		private System.Nullable<System.DateTime> _ssmalldatetime;
		
		private System.Nullable<short> _ssmallint;
		
		private string _ttext;
		
    #region Extensibility Method Definitions
    partial void OnLoaded();
    partial void OnValidate(System.Data.Linq.ChangeAction action);
    partial void OnCreated();
    partial void OnidChanging(int value);
    partial void OnidChanged();
    partial void OnccharChanging(string value);
    partial void OnccharChanged();
    partial void OnnnvarcharChanging(string value);
    partial void OnnnvarcharChanged();
    partial void OnbbigintChanging(System.Nullable<long> value);
    partial void OnbbigintChanged();
    partial void OnbbitChanging(System.Nullable<bool> value);
    partial void OnbbitChanged();
    partial void OnddatetimeChanging(System.Nullable<System.DateTime> value);
    partial void OnddatetimeChanged();
    partial void OnddecimalChanging(System.Nullable<decimal> value);
    partial void OnddecimalChanged();
    partial void OnffloatChanging(System.Nullable<double> value);
    partial void OnffloatChanged();
    partial void OniintChanging(System.Nullable<int> value);
    partial void OniintChanged();
    partial void OnmmoneyChanging(System.Nullable<decimal> value);
    partial void OnmmoneyChanged();
    partial void OnnntextChanging(string value);
    partial void OnnntextChanged();
    partial void OnnnumericChanging(System.Nullable<decimal> value);
    partial void OnnnumericChanged();
    partial void OnrrealChanging(System.Nullable<float> value);
    partial void OnrrealChanged();
    partial void OnssmalldatetimeChanging(System.Nullable<System.DateTime> value);
    partial void OnssmalldatetimeChanged();
    partial void OnssmallintChanging(System.Nullable<short> value);
    partial void OnssmallintChanged();
    partial void OnttextChanging(string value);
    partial void OnttextChanged();
    #endregion
		
		public testtable()
		{
			this.Initialize();
		}
		
		[Column(Storage="_id", AutoSync=AutoSync.OnInsert, DbType="Int NOT NULL IDENTITY", IsPrimaryKey=true, IsDbGenerated=true)]
		[DataMember(Order=1)]
		public int id
		{
			get
			{
				return this._id;
			}
			set
			{
				if ((this._id != value))
				{
					this.OnidChanging(value);
					this.SendPropertyChanging();
					this._id = value;
					this.SendPropertyChanged("id");
					this.OnidChanged();
				}
			}
		}
		
		[Column(Storage="_cchar", DbType="Char(10)")]
		[DataMember(Order=2)]
		public string cchar
		{
			get
			{
				return this._cchar;
			}
			set
			{
				if ((this._cchar != value))
				{
					this.OnccharChanging(value);
					this.SendPropertyChanging();
					this._cchar = value;
					this.SendPropertyChanged("cchar");
					this.OnccharChanged();
				}
			}
		}
		
		[Column(Storage="_nnvarchar", DbType="NVarChar(50)")]
		[DataMember(Order=3)]
		public string nnvarchar
		{
			get
			{
				return this._nnvarchar;
			}
			set
			{
				if ((this._nnvarchar != value))
				{
					this.OnnnvarcharChanging(value);
					this.SendPropertyChanging();
					this._nnvarchar = value;
					this.SendPropertyChanged("nnvarchar");
					this.OnnnvarcharChanged();
				}
			}
		}
		
		[Column(Storage="_bbigint", DbType="BigInt")]
		[DataMember(Order=4)]
		public System.Nullable<long> bbigint
		{
			get
			{
				return this._bbigint;
			}
			set
			{
				if ((this._bbigint != value))
				{
					this.OnbbigintChanging(value);
					this.SendPropertyChanging();
					this._bbigint = value;
					this.SendPropertyChanged("bbigint");
					this.OnbbigintChanged();
				}
			}
		}
		
		[Column(Storage="_bbit", DbType="Bit")]
		[DataMember(Order=5)]
		public System.Nullable<bool> bbit
		{
			get
			{
				return this._bbit;
			}
			set
			{
				if ((this._bbit != value))
				{
					this.OnbbitChanging(value);
					this.SendPropertyChanging();
					this._bbit = value;
					this.SendPropertyChanged("bbit");
					this.OnbbitChanged();
				}
			}
		}
		
		[Column(Storage="_ddatetime", DbType="DateTime")]
		[DataMember(Order=6)]
		public System.Nullable<System.DateTime> ddatetime
		{
			get
			{
				return this._ddatetime;
			}
			set
			{
				if ((this._ddatetime != value))
				{
					this.OnddatetimeChanging(value);
					this.SendPropertyChanging();
					this._ddatetime = value;
					this.SendPropertyChanged("ddatetime");
					this.OnddatetimeChanged();
				}
			}
		}
		
		[Column(Storage="_ddecimal", DbType="Decimal(18,0)")]
		[DataMember(Order=7)]
		public System.Nullable<decimal> ddecimal
		{
			get
			{
				return this._ddecimal;
			}
			set
			{
				if ((this._ddecimal != value))
				{
					this.OnddecimalChanging(value);
					this.SendPropertyChanging();
					this._ddecimal = value;
					this.SendPropertyChanged("ddecimal");
					this.OnddecimalChanged();
				}
			}
		}
		
		[Column(Storage="_ffloat", DbType="Float")]
		[DataMember(Order=8)]
		public System.Nullable<double> ffloat
		{
			get
			{
				return this._ffloat;
			}
			set
			{
				if ((this._ffloat != value))
				{
					this.OnffloatChanging(value);
					this.SendPropertyChanging();
					this._ffloat = value;
					this.SendPropertyChanged("ffloat");
					this.OnffloatChanged();
				}
			}
		}
		
		[Column(Storage="_iint", DbType="Int")]
		[DataMember(Order=9)]
		public System.Nullable<int> iint
		{
			get
			{
				return this._iint;
			}
			set
			{
				if ((this._iint != value))
				{
					this.OniintChanging(value);
					this.SendPropertyChanging();
					this._iint = value;
					this.SendPropertyChanged("iint");
					this.OniintChanged();
				}
			}
		}
		
		[Column(Storage="_mmoney", DbType="Money")]
		[DataMember(Order=10)]
		public System.Nullable<decimal> mmoney
		{
			get
			{
				return this._mmoney;
			}
			set
			{
				if ((this._mmoney != value))
				{
					this.OnmmoneyChanging(value);
					this.SendPropertyChanging();
					this._mmoney = value;
					this.SendPropertyChanged("mmoney");
					this.OnmmoneyChanged();
				}
			}
		}
		
		[Column(Storage="_nntext", DbType="NText", UpdateCheck=UpdateCheck.Never)]
		[DataMember(Order=11)]
		public string nntext
		{
			get
			{
				return this._nntext;
			}
			set
			{
				if ((this._nntext != value))
				{
					this.OnnntextChanging(value);
					this.SendPropertyChanging();
					this._nntext = value;
					this.SendPropertyChanged("nntext");
					this.OnnntextChanged();
				}
			}
		}
		
		[Column(Storage="_nnumeric", DbType="Decimal(18,0)")]
		[DataMember(Order=12)]
		public System.Nullable<decimal> nnumeric
		{
			get
			{
				return this._nnumeric;
			}
			set
			{
				if ((this._nnumeric != value))
				{
					this.OnnnumericChanging(value);
					this.SendPropertyChanging();
					this._nnumeric = value;
					this.SendPropertyChanged("nnumeric");
					this.OnnnumericChanged();
				}
			}
		}
		
		[Column(Storage="_rreal", DbType="Real")]
		[DataMember(Order=13)]
		public System.Nullable<float> rreal
		{
			get
			{
				return this._rreal;
			}
			set
			{
				if ((this._rreal != value))
				{
					this.OnrrealChanging(value);
					this.SendPropertyChanging();
					this._rreal = value;
					this.SendPropertyChanged("rreal");
					this.OnrrealChanged();
				}
			}
		}
		
		[Column(Storage="_ssmalldatetime", DbType="SmallDateTime")]
		[DataMember(Order=14)]
		public System.Nullable<System.DateTime> ssmalldatetime
		{
			get
			{
				return this._ssmalldatetime;
			}
			set
			{
				if ((this._ssmalldatetime != value))
				{
					this.OnssmalldatetimeChanging(value);
					this.SendPropertyChanging();
					this._ssmalldatetime = value;
					this.SendPropertyChanged("ssmalldatetime");
					this.OnssmalldatetimeChanged();
				}
			}
		}
		
		[Column(Storage="_ssmallint", DbType="SmallInt")]
		[DataMember(Order=15)]
		public System.Nullable<short> ssmallint
		{
			get
			{
				return this._ssmallint;
			}
			set
			{
				if ((this._ssmallint != value))
				{
					this.OnssmallintChanging(value);
					this.SendPropertyChanging();
					this._ssmallint = value;
					this.SendPropertyChanged("ssmallint");
					this.OnssmallintChanged();
				}
			}
		}
		
		[Column(Storage="_ttext", DbType="Text", UpdateCheck=UpdateCheck.Never)]
		[DataMember(Order=16)]
		public string ttext
		{
			get
			{
				return this._ttext;
			}
			set
			{
				if ((this._ttext != value))
				{
					this.OnttextChanging(value);
					this.SendPropertyChanging();
					this._ttext = value;
					this.SendPropertyChanged("ttext");
					this.OnttextChanged();
				}
			}
		}
		
		public event PropertyChangingEventHandler PropertyChanging;
		
		public event PropertyChangedEventHandler PropertyChanged;
		
		protected virtual void SendPropertyChanging()
		{
			if ((this.PropertyChanging != null))
			{
				this.PropertyChanging(this, emptyChangingEventArgs);
			}
		}
		
		protected virtual void SendPropertyChanged(String propertyName)
		{
			if ((this.PropertyChanged != null))
			{
				this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
			}
		}
		
		private void Initialize()
		{
			OnCreated();
		}
		
		[OnDeserializing()]
		[System.ComponentModel.EditorBrowsableAttribute(EditorBrowsableState.Never)]
		public void OnDeserializing(StreamingContext context)
		{
			this.Initialize();
		}
	}
	
	[Table(Name="dbo.Customers")]
	[DataContract()]
	public partial class Customer : INotifyPropertyChanging, INotifyPropertyChanged
	{
		
		private static PropertyChangingEventArgs emptyChangingEventArgs = new PropertyChangingEventArgs(String.Empty);
		
		private string _CustomerID;
		
		private string _CompanyName;
		
		private string _ContactName;
		
		private string _ContactTitle;
		
		private string _Address;
		
		private string _City;
		
		private string _Region;
		
		private string _PostalCode;
		
		private string _Country;
		
		private string _Phone;
		
		private string _Fax;
		
    #region Extensibility Method Definitions
    partial void OnLoaded();
    partial void OnValidate(System.Data.Linq.ChangeAction action);
    partial void OnCreated();
    partial void OnCustomerIDChanging(string value);
    partial void OnCustomerIDChanged();
    partial void OnCompanyNameChanging(string value);
    partial void OnCompanyNameChanged();
    partial void OnContactNameChanging(string value);
    partial void OnContactNameChanged();
    partial void OnContactTitleChanging(string value);
    partial void OnContactTitleChanged();
    partial void OnAddressChanging(string value);
    partial void OnAddressChanged();
    partial void OnCityChanging(string value);
    partial void OnCityChanged();
    partial void OnRegionChanging(string value);
    partial void OnRegionChanged();
    partial void OnPostalCodeChanging(string value);
    partial void OnPostalCodeChanged();
    partial void OnCountryChanging(string value);
    partial void OnCountryChanged();
    partial void OnPhoneChanging(string value);
    partial void OnPhoneChanged();
    partial void OnFaxChanging(string value);
    partial void OnFaxChanged();
    #endregion
		
		public Customer()
		{
			this.Initialize();
		}
		
		[Column(Storage="_CustomerID", DbType="NChar(5) NOT NULL", CanBeNull=false, IsPrimaryKey=true)]
		[DataMember(Order=1)]
		public string CustomerID
		{
			get
			{
				return this._CustomerID;
			}
			set
			{
				if ((this._CustomerID != value))
				{
					this.OnCustomerIDChanging(value);
					this.SendPropertyChanging();
					this._CustomerID = value;
					this.SendPropertyChanged("CustomerID");
					this.OnCustomerIDChanged();
				}
			}
		}
		
		[Column(Storage="_CompanyName", DbType="NVarChar(40) NOT NULL", CanBeNull=false)]
		[DataMember(Order=2)]
		public string CompanyName
		{
			get
			{
				return this._CompanyName;
			}
			set
			{
				if ((this._CompanyName != value))
				{
					this.OnCompanyNameChanging(value);
					this.SendPropertyChanging();
					this._CompanyName = value;
					this.SendPropertyChanged("CompanyName");
					this.OnCompanyNameChanged();
				}
			}
		}
		
		[Column(Storage="_ContactName", DbType="NVarChar(30)")]
		[DataMember(Order=3)]
		public string ContactName
		{
			get
			{
				return this._ContactName;
			}
			set
			{
				if ((this._ContactName != value))
				{
					this.OnContactNameChanging(value);
					this.SendPropertyChanging();
					this._ContactName = value;
					this.SendPropertyChanged("ContactName");
					this.OnContactNameChanged();
				}
			}
		}
		
		[Column(Storage="_ContactTitle", DbType="NVarChar(30)")]
		[DataMember(Order=4)]
		public string ContactTitle
		{
			get
			{
				return this._ContactTitle;
			}
			set
			{
				if ((this._ContactTitle != value))
				{
					this.OnContactTitleChanging(value);
					this.SendPropertyChanging();
					this._ContactTitle = value;
					this.SendPropertyChanged("ContactTitle");
					this.OnContactTitleChanged();
				}
			}
		}
		
		[Column(Storage="_Address", DbType="NVarChar(60)")]
		[DataMember(Order=5)]
		public string Address
		{
			get
			{
				return this._Address;
			}
			set
			{
				if ((this._Address != value))
				{
					this.OnAddressChanging(value);
					this.SendPropertyChanging();
					this._Address = value;
					this.SendPropertyChanged("Address");
					this.OnAddressChanged();
				}
			}
		}
		
		[Column(Storage="_City", DbType="NVarChar(15)")]
		[DataMember(Order=6)]
		public string City
		{
			get
			{
				return this._City;
			}
			set
			{
				if ((this._City != value))
				{
					this.OnCityChanging(value);
					this.SendPropertyChanging();
					this._City = value;
					this.SendPropertyChanged("City");
					this.OnCityChanged();
				}
			}
		}
		
		[Column(Storage="_Region", DbType="NVarChar(15)")]
		[DataMember(Order=7)]
		public string Region
		{
			get
			{
				return this._Region;
			}
			set
			{
				if ((this._Region != value))
				{
					this.OnRegionChanging(value);
					this.SendPropertyChanging();
					this._Region = value;
					this.SendPropertyChanged("Region");
					this.OnRegionChanged();
				}
			}
		}
		
		[Column(Storage="_PostalCode", DbType="NVarChar(10)")]
		[DataMember(Order=8)]
		public string PostalCode
		{
			get
			{
				return this._PostalCode;
			}
			set
			{
				if ((this._PostalCode != value))
				{
					this.OnPostalCodeChanging(value);
					this.SendPropertyChanging();
					this._PostalCode = value;
					this.SendPropertyChanged("PostalCode");
					this.OnPostalCodeChanged();
				}
			}
		}
		
		[Column(Storage="_Country", DbType="NVarChar(15)")]
		[DataMember(Order=9)]
		public string Country
		{
			get
			{
				return this._Country;
			}
			set
			{
				if ((this._Country != value))
				{
					this.OnCountryChanging(value);
					this.SendPropertyChanging();
					this._Country = value;
					this.SendPropertyChanged("Country");
					this.OnCountryChanged();
				}
			}
		}
		
		[Column(Storage="_Phone", DbType="NVarChar(24)")]
		[DataMember(Order=10)]
		public string Phone
		{
			get
			{
				return this._Phone;
			}
			set
			{
				if ((this._Phone != value))
				{
					this.OnPhoneChanging(value);
					this.SendPropertyChanging();
					this._Phone = value;
					this.SendPropertyChanged("Phone");
					this.OnPhoneChanged();
				}
			}
		}
		
		[Column(Storage="_Fax", DbType="NVarChar(24)")]
		[DataMember(Order=11)]
		public string Fax
		{
			get
			{
				return this._Fax;
			}
			set
			{
				if ((this._Fax != value))
				{
					this.OnFaxChanging(value);
					this.SendPropertyChanging();
					this._Fax = value;
					this.SendPropertyChanged("Fax");
					this.OnFaxChanged();
				}
			}
		}
		
		public event PropertyChangingEventHandler PropertyChanging;
		
		public event PropertyChangedEventHandler PropertyChanged;
		
		protected virtual void SendPropertyChanging()
		{
			if ((this.PropertyChanging != null))
			{
				this.PropertyChanging(this, emptyChangingEventArgs);
			}
		}
		
		protected virtual void SendPropertyChanged(String propertyName)
		{
			if ((this.PropertyChanged != null))
			{
				this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
			}
		}
		
		private void Initialize()
		{
			OnCreated();
		}
		
		[OnDeserializing()]
		[System.ComponentModel.EditorBrowsableAttribute(EditorBrowsableState.Never)]
		public void OnDeserializing(StreamingContext context)
		{
			this.Initialize();
		}
	}
}
#pragma warning restore 1591

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Australia Australia
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions