Click here to Skip to main content
15,895,142 members
Articles / Web Development / ASP.NET

Online Circular Chess in Silverlight, ASP.NET AJAX, WCF Web Services, and LINQ to SQL

Rate me:
Please Sign up or sign in to vote.
4.84/5 (61 votes)
31 Dec 2007CPOL34 min read 220.5K   1.9K   145  
An application for users to play Circular Chess over the internet based on Silverlight, ASP.NET AJAX, WCF Web Services, and LINQ to SQL.
#pragma warning disable 1591
//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a tool.
//     Runtime Version:2.0.50727.1433
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

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



[System.Data.Linq.Mapping.DatabaseAttribute(Name="CircularChess")]
public partial class CChessDataContext : System.Data.Linq.DataContext
{
	
	private static System.Data.Linq.Mapping.MappingSource mappingSource = new AttributeMappingSource();
	
  #region Extensibility Method Definitions
  partial void OnCreated();
  partial void InsertCChessMove(CChessMove instance);
  partial void UpdateCChessMove(CChessMove instance);
  partial void DeleteCChessMove(CChessMove instance);
  partial void InsertCChessPlayer(CChessPlayer instance);
  partial void UpdateCChessPlayer(CChessPlayer instance);
  partial void DeleteCChessPlayer(CChessPlayer instance);
  partial void InsertChatMessage(ChatMessage instance);
  partial void UpdateChatMessage(ChatMessage instance);
  partial void DeleteChatMessage(ChatMessage instance);
  partial void InsertCChessGamesPlayers(CChessGamesPlayers instance);
  partial void UpdateCChessGamesPlayers(CChessGamesPlayers instance);
  partial void DeleteCChessGamesPlayers(CChessGamesPlayers instance);
  partial void InsertCChessGame(CChessGame instance);
  partial void UpdateCChessGame(CChessGame instance);
  partial void DeleteCChessGame(CChessGame instance);
  #endregion
	
	public CChessDataContext() : 
			base(global::System.Configuration.ConfigurationManager.ConnectionStrings["CircularChessConnectionString"].ConnectionString, mappingSource)
	{
		OnCreated();
	}
	
	public CChessDataContext(string connection) : 
			base(connection, mappingSource)
	{
		OnCreated();
	}
	
	public CChessDataContext(System.Data.IDbConnection connection) : 
			base(connection, mappingSource)
	{
		OnCreated();
	}
	
	public CChessDataContext(string connection, System.Data.Linq.Mapping.MappingSource mappingSource) : 
			base(connection, mappingSource)
	{
		OnCreated();
	}
	
	public CChessDataContext(System.Data.IDbConnection connection, System.Data.Linq.Mapping.MappingSource mappingSource) : 
			base(connection, mappingSource)
	{
		OnCreated();
	}
	
	public System.Data.Linq.Table<CChessMove> CChessMoves
	{
		get
		{
			return this.GetTable<CChessMove>();
		}
	}
	
	public System.Data.Linq.Table<CChessPlayer> CChessPlayers
	{
		get
		{
			return this.GetTable<CChessPlayer>();
		}
	}
	
	public System.Data.Linq.Table<ChatMessage> ChatMessages
	{
		get
		{
			return this.GetTable<ChatMessage>();
		}
	}
	
	public System.Data.Linq.Table<CChessGamesPlayers> CChessGamesPlayers
	{
		get
		{
			return this.GetTable<CChessGamesPlayers>();
		}
	}
	
	public System.Data.Linq.Table<CChessGame> CChessGames
	{
		get
		{
			return this.GetTable<CChessGame>();
		}
	}
	
	[Function(Name="dbo.UpdateUserActivity")]
	public int UpdateUserActivity([Parameter(DbType="BigInt")] System.Nullable<long> player_id, [Parameter(DbType="Int")] System.Nullable<int> timestamp)
	{
		IExecuteResult result = this.ExecuteMethodCall(this, ((MethodInfo)(MethodInfo.GetCurrentMethod())), player_id, timestamp);
		return ((int)(result.ReturnValue));
	}
	
	[Function(Name="dbo.GetOnlinePlayers")]
	public ISingleResult<CChessPlayer> GetOnlinePlayers([Parameter(DbType="Int")] System.Nullable<int> legal_inactivity_seconds, [Parameter(DbType="Int")] System.Nullable<int> unix_timestamp)
	{
		IExecuteResult result = this.ExecuteMethodCall(this, ((MethodInfo)(MethodInfo.GetCurrentMethod())), legal_inactivity_seconds, unix_timestamp);
		return ((ISingleResult<CChessPlayer>)(result.ReturnValue));
	}
}

[Table(Name="dbo.games_moves")]
[DataContract()]
public partial class CChessMove : INotifyPropertyChanging, INotifyPropertyChanged
{
	
	private static PropertyChangingEventArgs emptyChangingEventArgs = new PropertyChangingEventArgs(String.Empty);
	
	private long _move_id;
	
	private long _game_id;
	
	private byte _piece_id;
	
	private byte _destination_ring;
	
	private byte _destination_square;
	
	private long _player_id;
	
	private EntityRef<CChessPlayer> _player;
	
	private EntityRef<CChessGame> _CChessGame;
	
    #region Extensibility Method Definitions
    partial void OnLoaded();
    partial void OnValidate(System.Data.Linq.ChangeAction action);
    partial void OnCreated();
    partial void Onmove_idChanging(long value);
    partial void Onmove_idChanged();
    partial void Ongame_idChanging(long value);
    partial void Ongame_idChanged();
    partial void Onpiece_idChanging(byte value);
    partial void Onpiece_idChanged();
    partial void Ondestination_ringChanging(byte value);
    partial void Ondestination_ringChanged();
    partial void Ondestination_squareChanging(byte value);
    partial void Ondestination_squareChanged();
    partial void Onplayer_idChanging(long value);
    partial void Onplayer_idChanged();
    #endregion
	
	public CChessMove()
	{
		this.Initialize();
	}
	
	[Column(Storage="_move_id", AutoSync=AutoSync.OnInsert, DbType="BigInt NOT NULL IDENTITY", IsPrimaryKey=true, IsDbGenerated=true)]
	[DataMember(Order=1)]
	public long move_id
	{
		get
		{
			return this._move_id;
		}
		set
		{
			if ((this._move_id != value))
			{
				this.Onmove_idChanging(value);
				this.SendPropertyChanging();
				this._move_id = value;
				this.SendPropertyChanged("move_id");
				this.Onmove_idChanged();
			}
		}
	}
	
	[Column(Storage="_game_id", DbType="BigInt NOT NULL")]
	[DataMember(Order=2)]
	public long game_id
	{
		get
		{
			return this._game_id;
		}
		set
		{
			if ((this._game_id != value))
			{
				if (this._CChessGame.HasLoadedOrAssignedValue)
				{
					throw new System.Data.Linq.ForeignKeyReferenceAlreadyHasValueException();
				}
				this.Ongame_idChanging(value);
				this.SendPropertyChanging();
				this._game_id = value;
				this.SendPropertyChanged("game_id");
				this.Ongame_idChanged();
			}
		}
	}
	
	[Column(Storage="_piece_id", DbType="TinyInt NOT NULL")]
	[DataMember(Order=3)]
	public byte piece_id
	{
		get
		{
			return this._piece_id;
		}
		set
		{
			if ((this._piece_id != value))
			{
				this.Onpiece_idChanging(value);
				this.SendPropertyChanging();
				this._piece_id = value;
				this.SendPropertyChanged("piece_id");
				this.Onpiece_idChanged();
			}
		}
	}
	
	[Column(Storage="_destination_ring", DbType="TinyInt NOT NULL")]
	[DataMember(Order=4)]
	public byte destination_ring
	{
		get
		{
			return this._destination_ring;
		}
		set
		{
			if ((this._destination_ring != value))
			{
				this.Ondestination_ringChanging(value);
				this.SendPropertyChanging();
				this._destination_ring = value;
				this.SendPropertyChanged("destination_ring");
				this.Ondestination_ringChanged();
			}
		}
	}
	
	[Column(Storage="_destination_square", DbType="TinyInt NOT NULL")]
	[DataMember(Order=5)]
	public byte destination_square
	{
		get
		{
			return this._destination_square;
		}
		set
		{
			if ((this._destination_square != value))
			{
				this.Ondestination_squareChanging(value);
				this.SendPropertyChanging();
				this._destination_square = value;
				this.SendPropertyChanged("destination_square");
				this.Ondestination_squareChanged();
			}
		}
	}
	
	[Column(Storage="_player_id", DbType="BigInt NOT NULL")]
	[DataMember(Order=6)]
	public long player_id
	{
		get
		{
			return this._player_id;
		}
		set
		{
			if ((this._player_id != value))
			{
				if (this._player.HasLoadedOrAssignedValue)
				{
					throw new System.Data.Linq.ForeignKeyReferenceAlreadyHasValueException();
				}
				this.Onplayer_idChanging(value);
				this.SendPropertyChanging();
				this._player_id = value;
				this.SendPropertyChanged("player_id");
				this.Onplayer_idChanged();
			}
		}
	}
	
	[Association(Name="CChessPlayer_CChessMove", Storage="_player", ThisKey="player_id", IsForeignKey=true)]
	public CChessPlayer CChessPlayer
	{
		get
		{
			return this._player.Entity;
		}
		set
		{
			CChessPlayer previousValue = this._player.Entity;
			if (((previousValue != value) 
						|| (this._player.HasLoadedOrAssignedValue == false)))
			{
				this.SendPropertyChanging();
				if ((previousValue != null))
				{
					this._player.Entity = null;
					previousValue.CChessMoves.Remove(this);
				}
				this._player.Entity = value;
				if ((value != null))
				{
					value.CChessMoves.Add(this);
					this._player_id = value.player_id;
				}
				else
				{
					this._player_id = default(long);
				}
				this.SendPropertyChanged("CChessPlayer");
			}
		}
	}
	
	[Association(Name="CChessGame_CChessMove", Storage="_CChessGame", ThisKey="game_id", IsForeignKey=true, DeleteOnNull=true, DeleteRule="CASCADE")]
	public CChessGame CChessGame
	{
		get
		{
			return this._CChessGame.Entity;
		}
		set
		{
			CChessGame previousValue = this._CChessGame.Entity;
			if (((previousValue != value) 
						|| (this._CChessGame.HasLoadedOrAssignedValue == false)))
			{
				this.SendPropertyChanging();
				if ((previousValue != null))
				{
					this._CChessGame.Entity = null;
					previousValue.CChessMoves.Remove(this);
				}
				this._CChessGame.Entity = value;
				if ((value != null))
				{
					value.CChessMoves.Add(this);
					this._game_id = value.game_id;
				}
				else
				{
					this._game_id = default(long);
				}
				this.SendPropertyChanged("CChessGame");
			}
		}
	}
	
	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()
	{
		this._player = default(EntityRef<CChessPlayer>);
		this._CChessGame = default(EntityRef<CChessGame>);
		OnCreated();
	}
	
	[OnDeserializing()]
	[System.ComponentModel.EditorBrowsableAttribute(EditorBrowsableState.Never)]
	public void OnDeserializing(StreamingContext context)
	{
		this.Initialize();
	}
}

[Table(Name="dbo.players")]
[DataContract()]
public partial class CChessPlayer : INotifyPropertyChanging, INotifyPropertyChanged
{
	
	private static PropertyChangingEventArgs emptyChangingEventArgs = new PropertyChangingEventArgs(String.Empty);
	
	private long _player_id;
	
	private string _player_nick;
	
	private int _last_activity;
	
	private EntitySet<CChessMove> _games_moves;
	
	private EntitySet<ChatMessage> _chat_tables;
	
	private EntitySet<CChessGamesPlayers> _CChessGamesPlayers;
	
	private bool serializing;
	
    #region Extensibility Method Definitions
    partial void OnLoaded();
    partial void OnValidate(System.Data.Linq.ChangeAction action);
    partial void OnCreated();
    partial void Onplayer_idChanging(long value);
    partial void Onplayer_idChanged();
    partial void Onplayer_nickChanging(string value);
    partial void Onplayer_nickChanged();
    partial void Onlast_activityChanging(int value);
    partial void Onlast_activityChanged();
    #endregion
	
	public CChessPlayer()
	{
		this.Initialize();
	}
	
	[Column(Storage="_player_id", AutoSync=AutoSync.OnInsert, DbType="BigInt NOT NULL IDENTITY", IsPrimaryKey=true, IsDbGenerated=true)]
	[DataMember(Order=1)]
	public long player_id
	{
		get
		{
			return this._player_id;
		}
		set
		{
			if ((this._player_id != value))
			{
				this.Onplayer_idChanging(value);
				this.SendPropertyChanging();
				this._player_id = value;
				this.SendPropertyChanged("player_id");
				this.Onplayer_idChanged();
			}
		}
	}
	
	[Column(Storage="_player_nick", DbType="NVarChar(50) NOT NULL", CanBeNull=false)]
	[DataMember(Order=2)]
	public string player_nick
	{
		get
		{
			return this._player_nick;
		}
		set
		{
			if ((this._player_nick != value))
			{
				this.Onplayer_nickChanging(value);
				this.SendPropertyChanging();
				this._player_nick = value;
				this.SendPropertyChanged("player_nick");
				this.Onplayer_nickChanged();
			}
		}
	}
	
	[Column(Storage="_last_activity", DbType="Int NOT NULL")]
	[DataMember(Order=3)]
	public int last_activity
	{
		get
		{
			return this._last_activity;
		}
		set
		{
			if ((this._last_activity != value))
			{
				this.Onlast_activityChanging(value);
				this.SendPropertyChanging();
				this._last_activity = value;
				this.SendPropertyChanged("last_activity");
				this.Onlast_activityChanged();
			}
		}
	}
	
	[Association(Name="CChessPlayer_CChessMove", Storage="_games_moves", OtherKey="player_id")]
	[DataMember(Order=4, EmitDefaultValue=false)]
	public EntitySet<CChessMove> CChessMoves
	{
		get
		{
			if ((this.serializing 
						&& (this._games_moves.HasLoadedOrAssignedValues == false)))
			{
				return null;
			}
			return this._games_moves;
		}
		set
		{
			this._games_moves.Assign(value);
		}
	}
	
	[Association(Name="CChessPlayer_ChatMessage", Storage="_chat_tables", OtherKey="message_writer")]
	[DataMember(Order=5, EmitDefaultValue=false)]
	public EntitySet<ChatMessage> ChatMessages
	{
		get
		{
			if ((this.serializing 
						&& (this._chat_tables.HasLoadedOrAssignedValues == false)))
			{
				return null;
			}
			return this._chat_tables;
		}
		set
		{
			this._chat_tables.Assign(value);
		}
	}
	
	[Association(Name="CChessPlayer_CChessGamesPlayers", Storage="_CChessGamesPlayers", OtherKey="player_id")]
	[DataMember(Order=6, EmitDefaultValue=false)]
	public EntitySet<CChessGamesPlayers> CChessGamesPlayers
	{
		get
		{
			if ((this.serializing 
						&& (this._CChessGamesPlayers.HasLoadedOrAssignedValues == false)))
			{
				return null;
			}
			return this._CChessGamesPlayers;
		}
		set
		{
			this._CChessGamesPlayers.Assign(value);
		}
	}
	
	public event PropertyChangingEventHandler PropertyChanging;
	
	public event PropertyChangedEventHandler PropertyChanged;
	
	protected virtual void SendPropertyChanging()
	{
		if ((this.PropertyChanging != null))
		{
			this.PropertyChanging(this, emptyChangingEventArgs);
		}
	}
	
	protected virtual void SendPropertyChanged(String propertyName)
	{
		if ((this.PropertyChanged != null))
		{
			this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
		}
	}
	
	private void attach_games_moves(CChessMove entity)
	{
		this.SendPropertyChanging();
		entity.CChessPlayer = this;
	}
	
	private void detach_games_moves(CChessMove entity)
	{
		this.SendPropertyChanging();
		entity.CChessPlayer = null;
	}
	
	private void attach_chat_tables(ChatMessage entity)
	{
		this.SendPropertyChanging();
		entity.CChessPlayer = this;
	}
	
	private void detach_chat_tables(ChatMessage entity)
	{
		this.SendPropertyChanging();
		entity.CChessPlayer = null;
	}
	
	private void attach_CChessGamesPlayers(CChessGamesPlayers entity)
	{
		this.SendPropertyChanging();
		entity.CChessPlayer = this;
	}
	
	private void detach_CChessGamesPlayers(CChessGamesPlayers entity)
	{
		this.SendPropertyChanging();
		entity.CChessPlayer = null;
	}
	
	private void Initialize()
	{
		this._games_moves = new EntitySet<CChessMove>(new Action<CChessMove>(this.attach_games_moves), new Action<CChessMove>(this.detach_games_moves));
		this._chat_tables = new EntitySet<ChatMessage>(new Action<ChatMessage>(this.attach_chat_tables), new Action<ChatMessage>(this.detach_chat_tables));
		this._CChessGamesPlayers = new EntitySet<CChessGamesPlayers>(new Action<CChessGamesPlayers>(this.attach_CChessGamesPlayers), new Action<CChessGamesPlayers>(this.detach_CChessGamesPlayers));
		OnCreated();
	}
	
	[OnDeserializing()]
	[System.ComponentModel.EditorBrowsableAttribute(EditorBrowsableState.Never)]
	public void OnDeserializing(StreamingContext context)
	{
		this.Initialize();
	}
	
	[OnSerializing()]
	[System.ComponentModel.EditorBrowsableAttribute(EditorBrowsableState.Never)]
	public void OnSerializing(StreamingContext context)
	{
		this.serializing = true;
	}
	
	[OnSerialized()]
	[System.ComponentModel.EditorBrowsableAttribute(EditorBrowsableState.Never)]
	public void OnSerialized(StreamingContext context)
	{
		this.serializing = false;
	}
}

[Table(Name="dbo.chat_table")]
[DataContract()]
public partial class ChatMessage : INotifyPropertyChanging, INotifyPropertyChanged
{
	
	private static PropertyChangingEventArgs emptyChangingEventArgs = new PropertyChangingEventArgs(String.Empty);
	
	private long _message_id;
	
	private long _message_writer;
	
	private string _message_content;
	
	private int _sent_timestamp;
	
	private EntityRef<CChessPlayer> _CChessPlayer;
	
    #region Extensibility Method Definitions
    partial void OnLoaded();
    partial void OnValidate(System.Data.Linq.ChangeAction action);
    partial void OnCreated();
    partial void Onmessage_idChanging(long value);
    partial void Onmessage_idChanged();
    partial void Onmessage_writerChanging(long value);
    partial void Onmessage_writerChanged();
    partial void Onmessage_contentChanging(string value);
    partial void Onmessage_contentChanged();
    partial void Onsent_timestampChanging(int value);
    partial void Onsent_timestampChanged();
    #endregion
	
	public ChatMessage()
	{
		this.Initialize();
	}
	
	[Column(Storage="_message_id", AutoSync=AutoSync.OnInsert, DbType="BigInt NOT NULL IDENTITY", IsPrimaryKey=true, IsDbGenerated=true)]
	[DataMember(Order=1)]
	public long message_id
	{
		get
		{
			return this._message_id;
		}
		set
		{
			if ((this._message_id != value))
			{
				this.Onmessage_idChanging(value);
				this.SendPropertyChanging();
				this._message_id = value;
				this.SendPropertyChanged("message_id");
				this.Onmessage_idChanged();
			}
		}
	}
	
	[Column(Storage="_message_writer", DbType="BigInt NOT NULL")]
	[DataMember(Order=2)]
	public long message_writer
	{
		get
		{
			return this._message_writer;
		}
		set
		{
			if ((this._message_writer != value))
			{
				if (this._CChessPlayer.HasLoadedOrAssignedValue)
				{
					throw new System.Data.Linq.ForeignKeyReferenceAlreadyHasValueException();
				}
				this.Onmessage_writerChanging(value);
				this.SendPropertyChanging();
				this._message_writer = value;
				this.SendPropertyChanged("message_writer");
				this.Onmessage_writerChanged();
			}
		}
	}
	
	[Column(Storage="_message_content", DbType="VarChar(MAX) NOT NULL", CanBeNull=false)]
	[DataMember(Order=3)]
	public string message_content
	{
		get
		{
			return this._message_content;
		}
		set
		{
			if ((this._message_content != value))
			{
				this.Onmessage_contentChanging(value);
				this.SendPropertyChanging();
				this._message_content = value;
				this.SendPropertyChanged("message_content");
				this.Onmessage_contentChanged();
			}
		}
	}
	
	[Column(Storage="_sent_timestamp", DbType="Int NOT NULL")]
	[DataMember(Order=4)]
	public int sent_timestamp
	{
		get
		{
			return this._sent_timestamp;
		}
		set
		{
			if ((this._sent_timestamp != value))
			{
				this.Onsent_timestampChanging(value);
				this.SendPropertyChanging();
				this._sent_timestamp = value;
				this.SendPropertyChanged("sent_timestamp");
				this.Onsent_timestampChanged();
			}
		}
	}
	
	[Association(Name="CChessPlayer_ChatMessage", Storage="_CChessPlayer", ThisKey="message_writer", IsForeignKey=true, DeleteOnNull=true, DeleteRule="CASCADE")]
	public CChessPlayer CChessPlayer
	{
		get
		{
			return this._CChessPlayer.Entity;
		}
		set
		{
			CChessPlayer previousValue = this._CChessPlayer.Entity;
			if (((previousValue != value) 
						|| (this._CChessPlayer.HasLoadedOrAssignedValue == false)))
			{
				this.SendPropertyChanging();
				if ((previousValue != null))
				{
					this._CChessPlayer.Entity = null;
					previousValue.ChatMessages.Remove(this);
				}
				this._CChessPlayer.Entity = value;
				if ((value != null))
				{
					value.ChatMessages.Add(this);
					this._message_writer = value.player_id;
				}
				else
				{
					this._message_writer = default(long);
				}
				this.SendPropertyChanged("CChessPlayer");
			}
		}
	}
	
	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()
	{
		this._CChessPlayer = default(EntityRef<CChessPlayer>);
		OnCreated();
	}
	
	[OnDeserializing()]
	[System.ComponentModel.EditorBrowsableAttribute(EditorBrowsableState.Never)]
	public void OnDeserializing(StreamingContext context)
	{
		this.Initialize();
	}
}

[Table(Name="dbo.games_players")]
[DataContract()]
public partial class CChessGamesPlayers : INotifyPropertyChanging, INotifyPropertyChanged
{
	
	private static PropertyChangingEventArgs emptyChangingEventArgs = new PropertyChangingEventArgs(String.Empty);
	
	private long _game_id;
	
	private long _player_id;
	
	private byte _color;
	
	private EntityRef<CChessPlayer> _CChessPlayer;
	
	private EntityRef<CChessGame> _CChessGame;
	
    #region Extensibility Method Definitions
    partial void OnLoaded();
    partial void OnValidate(System.Data.Linq.ChangeAction action);
    partial void OnCreated();
    partial void Ongame_idChanging(long value);
    partial void Ongame_idChanged();
    partial void Onplayer_idChanging(long value);
    partial void Onplayer_idChanged();
    partial void OncolorChanging(byte value);
    partial void OncolorChanged();
    #endregion
	
	public CChessGamesPlayers()
	{
		this.Initialize();
	}
	
	[Column(Storage="_game_id", DbType="BigInt NOT NULL", IsPrimaryKey=true)]
	[DataMember(Order=1)]
	public long game_id
	{
		get
		{
			return this._game_id;
		}
		set
		{
			if ((this._game_id != value))
			{
				if (this._CChessGame.HasLoadedOrAssignedValue)
				{
					throw new System.Data.Linq.ForeignKeyReferenceAlreadyHasValueException();
				}
				this.Ongame_idChanging(value);
				this.SendPropertyChanging();
				this._game_id = value;
				this.SendPropertyChanged("game_id");
				this.Ongame_idChanged();
			}
		}
	}
	
	[Column(Storage="_player_id", DbType="BigInt NOT NULL", IsPrimaryKey=true)]
	[DataMember(Order=2)]
	public long player_id
	{
		get
		{
			return this._player_id;
		}
		set
		{
			if ((this._player_id != value))
			{
				if (this._CChessPlayer.HasLoadedOrAssignedValue)
				{
					throw new System.Data.Linq.ForeignKeyReferenceAlreadyHasValueException();
				}
				this.Onplayer_idChanging(value);
				this.SendPropertyChanging();
				this._player_id = value;
				this.SendPropertyChanged("player_id");
				this.Onplayer_idChanged();
			}
		}
	}
	
	[Column(Storage="_color", DbType="TinyInt NOT NULL")]
	[DataMember(Order=3)]
	public byte color
	{
		get
		{
			return this._color;
		}
		set
		{
			if ((this._color != value))
			{
				this.OncolorChanging(value);
				this.SendPropertyChanging();
				this._color = value;
				this.SendPropertyChanged("color");
				this.OncolorChanged();
			}
		}
	}
	
	[Association(Name="CChessPlayer_CChessGamesPlayers", Storage="_CChessPlayer", ThisKey="player_id", IsForeignKey=true)]
	public CChessPlayer CChessPlayer
	{
		get
		{
			return this._CChessPlayer.Entity;
		}
		set
		{
			CChessPlayer previousValue = this._CChessPlayer.Entity;
			if (((previousValue != value) 
						|| (this._CChessPlayer.HasLoadedOrAssignedValue == false)))
			{
				this.SendPropertyChanging();
				if ((previousValue != null))
				{
					this._CChessPlayer.Entity = null;
					previousValue.CChessGamesPlayers.Remove(this);
				}
				this._CChessPlayer.Entity = value;
				if ((value != null))
				{
					value.CChessGamesPlayers.Add(this);
					this._player_id = value.player_id;
				}
				else
				{
					this._player_id = default(long);
				}
				this.SendPropertyChanged("CChessPlayer");
			}
		}
	}
	
	[Association(Name="CChessGame_CChessGamesPlayers", Storage="_CChessGame", ThisKey="game_id", IsForeignKey=true, DeleteOnNull=true, DeleteRule="CASCADE")]
	public CChessGame CChessGame
	{
		get
		{
			return this._CChessGame.Entity;
		}
		set
		{
			CChessGame previousValue = this._CChessGame.Entity;
			if (((previousValue != value) 
						|| (this._CChessGame.HasLoadedOrAssignedValue == false)))
			{
				this.SendPropertyChanging();
				if ((previousValue != null))
				{
					this._CChessGame.Entity = null;
					previousValue.CChessGamesPlayers.Remove(this);
				}
				this._CChessGame.Entity = value;
				if ((value != null))
				{
					value.CChessGamesPlayers.Add(this);
					this._game_id = value.game_id;
				}
				else
				{
					this._game_id = default(long);
				}
				this.SendPropertyChanged("CChessGame");
			}
		}
	}
	
	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()
	{
		this._CChessPlayer = default(EntityRef<CChessPlayer>);
		this._CChessGame = default(EntityRef<CChessGame>);
		OnCreated();
	}
	
	[OnDeserializing()]
	[System.ComponentModel.EditorBrowsableAttribute(EditorBrowsableState.Never)]
	public void OnDeserializing(StreamingContext context)
	{
		this.Initialize();
	}
}

[Table(Name="dbo.games")]
[DataContract()]
public partial class CChessGame : INotifyPropertyChanging, INotifyPropertyChanged
{
	
	private static PropertyChangingEventArgs emptyChangingEventArgs = new PropertyChangingEventArgs(String.Empty);
	
	private long _game_id;
	
	private byte _game_state;
	
	private EntitySet<CChessMove> _CChessMoves;
	
	private EntitySet<CChessGamesPlayers> _CChessGamesPlayers;
	
	private bool serializing;
	
    #region Extensibility Method Definitions
    partial void OnLoaded();
    partial void OnValidate(System.Data.Linq.ChangeAction action);
    partial void OnCreated();
    partial void Ongame_idChanging(long value);
    partial void Ongame_idChanged();
    partial void Ongame_stateChanging(byte value);
    partial void Ongame_stateChanged();
    #endregion
	
	public CChessGame()
	{
		this.Initialize();
	}
	
	[Column(Storage="_game_id", AutoSync=AutoSync.OnInsert, DbType="BigInt NOT NULL IDENTITY", IsPrimaryKey=true, IsDbGenerated=true)]
	[DataMember(Order=1)]
	public long game_id
	{
		get
		{
			return this._game_id;
		}
		set
		{
			if ((this._game_id != value))
			{
				this.Ongame_idChanging(value);
				this.SendPropertyChanging();
				this._game_id = value;
				this.SendPropertyChanged("game_id");
				this.Ongame_idChanged();
			}
		}
	}
	
	[Column(Storage="_game_state", DbType="TinyInt NOT NULL")]
	[DataMember(Order=2)]
	public byte game_state
	{
		get
		{
			return this._game_state;
		}
		set
		{
			if ((this._game_state != value))
			{
				this.Ongame_stateChanging(value);
				this.SendPropertyChanging();
				this._game_state = value;
				this.SendPropertyChanged("game_state");
				this.Ongame_stateChanged();
			}
		}
	}
	
	[Association(Name="CChessGame_CChessMove", Storage="_CChessMoves", OtherKey="game_id")]
	[DataMember(Order=3, EmitDefaultValue=false)]
	public EntitySet<CChessMove> CChessMoves
	{
		get
		{
			if ((this.serializing 
						&& (this._CChessMoves.HasLoadedOrAssignedValues == false)))
			{
				return null;
			}
			return this._CChessMoves;
		}
		set
		{
			this._CChessMoves.Assign(value);
		}
	}
	
	[Association(Name="CChessGame_CChessGamesPlayers", Storage="_CChessGamesPlayers", OtherKey="game_id")]
	[DataMember(Order=4, EmitDefaultValue=false)]
	public EntitySet<CChessGamesPlayers> CChessGamesPlayers
	{
		get
		{
			if ((this.serializing 
						&& (this._CChessGamesPlayers.HasLoadedOrAssignedValues == false)))
			{
				return null;
			}
			return this._CChessGamesPlayers;
		}
		set
		{
			this._CChessGamesPlayers.Assign(value);
		}
	}
	
	public event PropertyChangingEventHandler PropertyChanging;
	
	public event PropertyChangedEventHandler PropertyChanged;
	
	protected virtual void SendPropertyChanging()
	{
		if ((this.PropertyChanging != null))
		{
			this.PropertyChanging(this, emptyChangingEventArgs);
		}
	}
	
	protected virtual void SendPropertyChanged(String propertyName)
	{
		if ((this.PropertyChanged != null))
		{
			this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
		}
	}
	
	private void attach_CChessMoves(CChessMove entity)
	{
		this.SendPropertyChanging();
		entity.CChessGame = this;
	}
	
	private void detach_CChessMoves(CChessMove entity)
	{
		this.SendPropertyChanging();
		entity.CChessGame = null;
	}
	
	private void attach_CChessGamesPlayers(CChessGamesPlayers entity)
	{
		this.SendPropertyChanging();
		entity.CChessGame = this;
	}
	
	private void detach_CChessGamesPlayers(CChessGamesPlayers entity)
	{
		this.SendPropertyChanging();
		entity.CChessGame = null;
	}
	
	private void Initialize()
	{
		this._CChessMoves = new EntitySet<CChessMove>(new Action<CChessMove>(this.attach_CChessMoves), new Action<CChessMove>(this.detach_CChessMoves));
		this._CChessGamesPlayers = new EntitySet<CChessGamesPlayers>(new Action<CChessGamesPlayers>(this.attach_CChessGamesPlayers), new Action<CChessGamesPlayers>(this.detach_CChessGamesPlayers));
		OnCreated();
	}
	
	[OnDeserializing()]
	[System.ComponentModel.EditorBrowsableAttribute(EditorBrowsableState.Never)]
	public void OnDeserializing(StreamingContext context)
	{
		this.Initialize();
	}
	
	[OnSerializing()]
	[System.ComponentModel.EditorBrowsableAttribute(EditorBrowsableState.Never)]
	public void OnSerializing(StreamingContext context)
	{
		this.serializing = true;
	}
	
	[OnSerialized()]
	[System.ComponentModel.EditorBrowsableAttribute(EditorBrowsableState.Never)]
	public void OnSerialized(StreamingContext context)
	{
		this.serializing = false;
	}
}
#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
Israel Israel
My name is Julian, I was born in Argentina, but I've been living in Israel for 6 years already. I'm a high school student in my last year, I study computer science, physics and math.
Other than programming, I really enjoy watching anime and reading manga.

Comments and Discussions