Link to home
Start Free TrialLog in
Avatar of veruthandai
veruthandaiFlag for United States of America

asked on

LINQ Query by Name

I have three tables...

Elements
- Id
- Name

Keys
- Id
- ElementId
- Value
- UserId

Users
- Id
- Name

What I basically want to do is to figure out a way to call item.Keys["Element Name"].Value so that I can use the Keys like an indexing system. Any ideas on a LINQ query that would express this?

It's kind of difficult to express. Essentially I need to get the index of the Keys as it is attached to another table where the Element.Name is equal to the expression.

So let's assume..

Users
1 - "Stacey"

Elements
1 - "Age"

Keys
1  - 1 - 25 - 1

In my Model, I would see

item.Keys[ -index can go here to get the key- ].Value

I'm trying to find the best way to lookup the Index based on the Label I want. I am using the Elements table between Keys and Tags to enforce non-duplication due to typos and case-sensitivity. So the Elements is behaving like a dictionary of valid Key and Tag names.

I know of the .Single( e => Element.Name == "Age") approach, but I cannot seem to figure out how to translate this into the index filed. The problem is that the array will not always be indexed the same for every single user. Some of them might have "Age" at index 0, some might have it at Index 37.
Avatar of Fernando Soto
Fernando Soto
Flag of United States of America image

Hi veruthandai;

Not sure of the question and what you want to accomplish. You have 3 MS SQL database tables, Elements, Keys, and Users and some how you query the database and pull down the values in those table into your program. Now what do you need to accomplish?

Fernando
Avatar of veruthandai

ASKER

I'm using ASP.NET MVC and LINQ to SQL to access the data. I need to figure out how to query the index of a key in it's array based on the name of the Element in the key's ElementId.
For example, in my Page View, I have the following code.
(assume 'item' is a User instance)

<td>
<%= Html.Encode( item.Keys[0].Value ) %>
</td>
This works fine right now, because all of the items inserted were just test data - so the [0] index is the Key for each User that has an ElementId of 1 ( the Element with the Name "Age").
This will not be the case in the future, as each item may be constructed differently by the users of the system. I need to ensure that the keys are usable by name instead of KNOWN index. So what I need is ...
Html.Encode( item.Keys["Age"].Value )
where putting in "Age" returns the Index of the key that matches that ElementId.
Is item in item.Keys[ -index can go here to get the key- ].Value the DataContext?
Here, let me give you the full schema. I'm sorry it is so large and cumbersome.
I greatly appreciate your help. I'm very new to LINQ, so this is all very confusing to me.

#pragma warning disable 1591
//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a tool.
//     Runtime Version:2.0.50727.3074
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
 
namespace Lithium
{
	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="Database")]
	public partial class DatabaseDataContext : System.Data.Linq.DataContext
	{
		
		private static System.Data.Linq.Mapping.MappingSource mappingSource = new AttributeMappingSource();
		
    #region Extensibility Method Definitions
    partial void OnCreated();
    partial void InsertAchievement(Achievement instance);
    partial void UpdateAchievement(Achievement instance);
    partial void DeleteAchievement(Achievement instance);
    partial void InsertToken(Token instance);
    partial void UpdateToken(Token instance);
    partial void DeleteToken(Token instance);
    partial void InsertAdjustment(Adjustment instance);
    partial void UpdateAdjustment(Adjustment instance);
    partial void DeleteAdjustment(Adjustment instance);
    partial void InsertAttendee(Attendee instance);
    partial void UpdateAttendee(Attendee instance);
    partial void DeleteAttendee(Attendee instance);
    partial void InsertCharacter(Character instance);
    partial void UpdateCharacter(Character instance);
    partial void DeleteCharacter(Character instance);
    partial void InsertElement(Element instance);
    partial void UpdateElement(Element instance);
    partial void DeleteElement(Element instance);
    partial void InsertEvent(Event instance);
    partial void UpdateEvent(Event instance);
    partial void DeleteEvent(Event instance);
    partial void InsertGroup(Group instance);
    partial void UpdateGroup(Group instance);
    partial void DeleteGroup(Group instance);
    partial void InsertKey(Key instance);
    partial void UpdateKey(Key instance);
    partial void DeleteKey(Key instance);
    partial void InsertLog(Log instance);
    partial void UpdateLog(Log instance);
    partial void DeleteLog(Log instance);
    partial void InsertMeasure(Measure instance);
    partial void UpdateMeasure(Measure instance);
    partial void DeleteMeasure(Measure instance);
    partial void InsertMember(Member instance);
    partial void UpdateMember(Member instance);
    partial void DeleteMember(Member instance);
    partial void InsertPair(Pair instance);
    partial void UpdatePair(Pair instance);
    partial void DeletePair(Pair instance);
    partial void InsertPassword(Password instance);
    partial void UpdatePassword(Password instance);
    partial void DeletePassword(Password instance);
    partial void InsertReward(Reward instance);
    partial void UpdateReward(Reward instance);
    partial void DeleteReward(Reward instance);
    partial void InsertRole(Role instance);
    partial void UpdateRole(Role instance);
    partial void DeleteRole(Role instance);
    partial void InsertRoster(Roster instance);
    partial void UpdateRoster(Roster instance);
    partial void DeleteRoster(Roster instance);
    partial void InsertRule(Rule instance);
    partial void UpdateRule(Rule instance);
    partial void DeleteRule(Rule instance);
    partial void InsertTag(Tag instance);
    partial void UpdateTag(Tag instance);
    partial void DeleteTag(Tag instance);
    partial void InsertTeam(Team instance);
    partial void UpdateTeam(Team instance);
    partial void DeleteTeam(Team instance);
    partial void InsertTimecard(Timecard instance);
    partial void UpdateTimecard(Timecard instance);
    partial void DeleteTimecard(Timecard instance);
    partial void InsertTimespan(Timespan instance);
    partial void UpdateTimespan(Timespan instance);
    partial void DeleteTimespan(Timespan instance);
    partial void InsertLabel(Label instance);
    partial void UpdateLabel(Label instance);
    partial void DeleteLabel(Label instance);
    #endregion
		
		public DatabaseDataContext() : 
				base(global::System.Configuration.ConfigurationManager.ConnectionStrings["DatabaseConnectionString"].ConnectionString, mappingSource)
		{
			OnCreated();
		}
		
		public DatabaseDataContext(string connection) : 
				base(connection, mappingSource)
		{
			OnCreated();
		}
		
		public DatabaseDataContext(System.Data.IDbConnection connection) : 
				base(connection, mappingSource)
		{
			OnCreated();
		}
		
		public DatabaseDataContext(string connection, System.Data.Linq.Mapping.MappingSource mappingSource) : 
				base(connection, mappingSource)
		{
			OnCreated();
		}
		
		public DatabaseDataContext(System.Data.IDbConnection connection, System.Data.Linq.Mapping.MappingSource mappingSource) : 
				base(connection, mappingSource)
		{
			OnCreated();
		}
		
		public System.Data.Linq.Table<Achievement> Achievements
		{
			get
			{
				return this.GetTable<Achievement>();
			}
		}
		
		public System.Data.Linq.Table<Token> Tokens
		{
			get
			{
				return this.GetTable<Token>();
			}
		}
		
		public System.Data.Linq.Table<Adjustment> Adjustments
		{
			get
			{
				return this.GetTable<Adjustment>();
			}
		}
		
		public System.Data.Linq.Table<Attendee> Attendees
		{
			get
			{
				return this.GetTable<Attendee>();
			}
		}
		
		public System.Data.Linq.Table<Character> Characters
		{
			get
			{
				return this.GetTable<Character>();
			}
		}
		
		public System.Data.Linq.Table<Element> Elements
		{
			get
			{
				return this.GetTable<Element>();
			}
		}
		
		public System.Data.Linq.Table<Event> Events
		{
			get
			{
				return this.GetTable<Event>();
			}
		}
		
		public System.Data.Linq.Table<Group> Groups
		{
			get
			{
				return this.GetTable<Group>();
			}
		}
		
		public System.Data.Linq.Table<Key> Keys
		{
			get
			{
				return this.GetTable<Key>();
			}
		}
		
		public System.Data.Linq.Table<Log> Logs
		{
			get
			{
				return this.GetTable<Log>();
			}
		}
		
		public System.Data.Linq.Table<Measure> Measures
		{
			get
			{
				return this.GetTable<Measure>();
			}
		}
		
		public System.Data.Linq.Table<Member> Members
		{
			get
			{
				return this.GetTable<Member>();
			}
		}
		
		public System.Data.Linq.Table<Pair> Pairs
		{
			get
			{
				return this.GetTable<Pair>();
			}
		}
		
		public System.Data.Linq.Table<Password> Passwords
		{
			get
			{
				return this.GetTable<Password>();
			}
		}
		
		public System.Data.Linq.Table<Reward> Rewards
		{
			get
			{
				return this.GetTable<Reward>();
			}
		}
		
		public System.Data.Linq.Table<Role> Roles
		{
			get
			{
				return this.GetTable<Role>();
			}
		}
		
		public System.Data.Linq.Table<Roster> Rosters
		{
			get
			{
				return this.GetTable<Roster>();
			}
		}
		
		public System.Data.Linq.Table<Rule> Rules
		{
			get
			{
				return this.GetTable<Rule>();
			}
		}
		
		public System.Data.Linq.Table<Tag> Tags
		{
			get
			{
				return this.GetTable<Tag>();
			}
		}
		
		public System.Data.Linq.Table<Team> Teams
		{
			get
			{
				return this.GetTable<Team>();
			}
		}
		
		public System.Data.Linq.Table<Timecard> Timecards
		{
			get
			{
				return this.GetTable<Timecard>();
			}
		}
		
		public System.Data.Linq.Table<Timespan> Timespans
		{
			get
			{
				return this.GetTable<Timespan>();
			}
		}
		
		public System.Data.Linq.Table<Label> Labels
		{
			get
			{
				return this.GetTable<Label>();
			}
		}
	}
	
	[Table(Name="dbo.Achievements")]
	[DataContract()]
	public partial class Achievement : INotifyPropertyChanging, INotifyPropertyChanged
	{
		
		private static PropertyChangingEventArgs emptyChangingEventArgs = new PropertyChangingEventArgs(String.Empty);
		
		private int _Id;
		
		private string _Name;
		
		private int _RosterId;
		
		private int _TokenId;
		
		private EntityRef<Token> _Token;
		
		private EntityRef<Roster> _Roster;
		
    #region Extensibility Method Definitions
    partial void OnLoaded();
    partial void OnValidate(System.Data.Linq.ChangeAction action);
    partial void OnCreated();
    partial void OnIdChanging(int value);
    partial void OnIdChanged();
    partial void OnNameChanging(string value);
    partial void OnNameChanged();
    partial void OnRosterIdChanging(int value);
    partial void OnRosterIdChanged();
    partial void OnTokenIdChanging(int value);
    partial void OnTokenIdChanged();
    #endregion
		
		public Achievement()
		{
			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="_Name", DbType="NVarChar(512) NOT NULL", CanBeNull=false)]
		[DataMember(Order=2)]
		public string Name
		{
			get
			{
				return this._Name;
			}
			set
			{
				if ((this._Name != value))
				{
					this.OnNameChanging(value);
					this.SendPropertyChanging();
					this._Name = value;
					this.SendPropertyChanged("Name");
					this.OnNameChanged();
				}
			}
		}
		
		[Column(Storage="_RosterId", DbType="Int NOT NULL")]
		[DataMember(Order=3)]
		public int RosterId
		{
			get
			{
				return this._RosterId;
			}
			set
			{
				if ((this._RosterId != value))
				{
					if (this._Roster.HasLoadedOrAssignedValue)
					{
						throw new System.Data.Linq.ForeignKeyReferenceAlreadyHasValueException();
					}
					this.OnRosterIdChanging(value);
					this.SendPropertyChanging();
					this._RosterId = value;
					this.SendPropertyChanged("RosterId");
					this.OnRosterIdChanged();
				}
			}
		}
		
		[Column(Storage="_TokenId", DbType="Int NOT NULL")]
		[DataMember(Order=4)]
		public int TokenId
		{
			get
			{
				return this._TokenId;
			}
			set
			{
				if ((this._TokenId != value))
				{
					if (this._Token.HasLoadedOrAssignedValue)
					{
						throw new System.Data.Linq.ForeignKeyReferenceAlreadyHasValueException();
					}
					this.OnTokenIdChanging(value);
					this.SendPropertyChanging();
					this._TokenId = value;
					this.SendPropertyChanged("TokenId");
					this.OnTokenIdChanged();
				}
			}
		}
		
		[Association(Name="Token_Achievement", Storage="_Token", ThisKey="TokenId", OtherKey="Id", IsForeignKey=true)]
		public Token Token
		{
			get
			{
				return this._Token.Entity;
			}
			set
			{
				Token previousValue = this._Token.Entity;
				if (((previousValue != value) 
							|| (this._Token.HasLoadedOrAssignedValue == false)))
				{
					this.SendPropertyChanging();
					if ((previousValue != null))
					{
						this._Token.Entity = null;
						previousValue.Achievements.Remove(this);
					}
					this._Token.Entity = value;
					if ((value != null))
					{
						value.Achievements.Add(this);
						this._TokenId = value.Id;
					}
					else
					{
						this._TokenId = default(int);
					}
					this.SendPropertyChanged("Token");
				}
			}
		}
		
		[Association(Name="Roster_Achievement", Storage="_Roster", ThisKey="RosterId", OtherKey="Id", IsForeignKey=true)]
		public Roster Roster
		{
			get
			{
				return this._Roster.Entity;
			}
			set
			{
				Roster previousValue = this._Roster.Entity;
				if (((previousValue != value) 
							|| (this._Roster.HasLoadedOrAssignedValue == false)))
				{
					this.SendPropertyChanging();
					if ((previousValue != null))
					{
						this._Roster.Entity = null;
						previousValue.Achievements.Remove(this);
					}
					this._Roster.Entity = value;
					if ((value != null))
					{
						value.Achievements.Add(this);
						this._RosterId = value.Id;
					}
					else
					{
						this._RosterId = default(int);
					}
					this.SendPropertyChanged("Roster");
				}
			}
		}
		
		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._Token = default(EntityRef<Token>);
			this._Roster = default(EntityRef<Roster>);
			OnCreated();
		}
		
		[OnDeserializing()]
		[System.ComponentModel.EditorBrowsableAttribute(EditorBrowsableState.Never)]
		public void OnDeserializing(StreamingContext context)
		{
			this.Initialize();
		}
	}
	
	[Table(Name="dbo.Tokens")]
	[DataContract()]
	public partial class Token : INotifyPropertyChanging, INotifyPropertyChanged
	{
		
		private static PropertyChangingEventArgs emptyChangingEventArgs = new PropertyChangingEventArgs(String.Empty);
		
		private int _Id;
		
		private double _Value;
		
		private EntitySet<Achievement> _Achievements;
		
		private EntitySet<Adjustment> _Adjustments;
		
		private EntitySet<Reward> _Rewards;
		
		private bool serializing;
		
    #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 OnValueChanging(double value);
    partial void OnValueChanged();
    #endregion
		
		public Token()
		{
			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="_Value", DbType="Float NOT NULL")]
		[DataMember(Order=2)]
		public double Value
		{
			get
			{
				return this._Value;
			}
			set
			{
				if ((this._Value != value))
				{
					this.OnValueChanging(value);
					this.SendPropertyChanging();
					this._Value = value;
					this.SendPropertyChanged("Value");
					this.OnValueChanged();
				}
			}
		}
		
		[Association(Name="Token_Achievement", Storage="_Achievements", ThisKey="Id", OtherKey="TokenId")]
		[DataMember(Order=3, EmitDefaultValue=false)]
		public EntitySet<Achievement> Achievements
		{
			get
			{
				if ((this.serializing 
							&& (this._Achievements.HasLoadedOrAssignedValues == false)))
				{
					return null;
				}
				return this._Achievements;
			}
			set
			{
				this._Achievements.Assign(value);
			}
		}
		
		[Association(Name="Token_Adjustment", Storage="_Adjustments", ThisKey="Id", OtherKey="TokenId")]
		[DataMember(Order=4, EmitDefaultValue=false)]
		public EntitySet<Adjustment> Adjustments
		{
			get
			{
				if ((this.serializing 
							&& (this._Adjustments.HasLoadedOrAssignedValues == false)))
				{
					return null;
				}
				return this._Adjustments;
			}
			set
			{
				this._Adjustments.Assign(value);
			}
		}
		
		[Association(Name="Token_Reward", Storage="_Rewards", ThisKey="Id", OtherKey="TokenId")]
		[DataMember(Order=5, EmitDefaultValue=false)]
		public EntitySet<Reward> Rewards
		{
			get
			{
				if ((this.serializing 
							&& (this._Rewards.HasLoadedOrAssignedValues == false)))
				{
					return null;
				}
				return this._Rewards;
			}
			set
			{
				this._Rewards.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_Achievements(Achievement entity)
		{
			this.SendPropertyChanging();
			entity.Token = this;
		}
		
		private void detach_Achievements(Achievement entity)
		{
			this.SendPropertyChanging();
			entity.Token = null;
		}
		
		private void attach_Adjustments(Adjustment entity)
		{
			this.SendPropertyChanging();
			entity.Token = this;
		}
		
		private void detach_Adjustments(Adjustment entity)
		{
			this.SendPropertyChanging();
			entity.Token = null;
		}
		
		private void attach_Rewards(Reward entity)
		{
			this.SendPropertyChanging();
			entity.Token = this;
		}
		
		private void detach_Rewards(Reward entity)
		{
			this.SendPropertyChanging();
			entity.Token = null;
		}
		
		private void Initialize()
		{
			this._Achievements = new EntitySet<Achievement>(new Action<Achievement>(this.attach_Achievements), new Action<Achievement>(this.detach_Achievements));
			this._Adjustments = new EntitySet<Adjustment>(new Action<Adjustment>(this.attach_Adjustments), new Action<Adjustment>(this.detach_Adjustments));
			this._Rewards = new EntitySet<Reward>(new Action<Reward>(this.attach_Rewards), new Action<Reward>(this.detach_Rewards));
			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.Adjustments")]
	[DataContract()]
	public partial class Adjustment : INotifyPropertyChanging, INotifyPropertyChanged
	{
		
		private static PropertyChangingEventArgs emptyChangingEventArgs = new PropertyChangingEventArgs(String.Empty);
		
		private int _Id;
		
		private int _CharacterId;
		
		private int _TokenId;
		
		private EntityRef<Token> _Token;
		
		private EntityRef<Character> _Character;
		
    #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 OnCharacterIdChanging(int value);
    partial void OnCharacterIdChanged();
    partial void OnTokenIdChanging(int value);
    partial void OnTokenIdChanged();
    #endregion
		
		public Adjustment()
		{
			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="_CharacterId", DbType="Int NOT NULL")]
		[DataMember(Order=2)]
		public int CharacterId
		{
			get
			{
				return this._CharacterId;
			}
			set
			{
				if ((this._CharacterId != value))
				{
					if (this._Character.HasLoadedOrAssignedValue)
					{
						throw new System.Data.Linq.ForeignKeyReferenceAlreadyHasValueException();
					}
					this.OnCharacterIdChanging(value);
					this.SendPropertyChanging();
					this._CharacterId = value;
					this.SendPropertyChanged("CharacterId");
					this.OnCharacterIdChanged();
				}
			}
		}
		
		[Column(Storage="_TokenId", DbType="Int NOT NULL")]
		[DataMember(Order=3)]
		public int TokenId
		{
			get
			{
				return this._TokenId;
			}
			set
			{
				if ((this._TokenId != value))
				{
					if (this._Token.HasLoadedOrAssignedValue)
					{
						throw new System.Data.Linq.ForeignKeyReferenceAlreadyHasValueException();
					}
					this.OnTokenIdChanging(value);
					this.SendPropertyChanging();
					this._TokenId = value;
					this.SendPropertyChanged("TokenId");
					this.OnTokenIdChanged();
				}
			}
		}
		
		[Association(Name="Token_Adjustment", Storage="_Token", ThisKey="TokenId", OtherKey="Id", IsForeignKey=true)]
		public Token Token
		{
			get
			{
				return this._Token.Entity;
			}
			set
			{
				Token previousValue = this._Token.Entity;
				if (((previousValue != value) 
							|| (this._Token.HasLoadedOrAssignedValue == false)))
				{
					this.SendPropertyChanging();
					if ((previousValue != null))
					{
						this._Token.Entity = null;
						previousValue.Adjustments.Remove(this);
					}
					this._Token.Entity = value;
					if ((value != null))
					{
						value.Adjustments.Add(this);
						this._TokenId = value.Id;
					}
					else
					{
						this._TokenId = default(int);
					}
					this.SendPropertyChanged("Token");
				}
			}
		}
		
		[Association(Name="Character_Adjustment", Storage="_Character", ThisKey="CharacterId", OtherKey="Id", IsForeignKey=true)]
		public Character Character
		{
			get
			{
				return this._Character.Entity;
			}
			set
			{
				Character previousValue = this._Character.Entity;
				if (((previousValue != value) 
							|| (this._Character.HasLoadedOrAssignedValue == false)))
				{
					this.SendPropertyChanging();
					if ((previousValue != null))
					{
						this._Character.Entity = null;
						previousValue.Adjustments.Remove(this);
					}
					this._Character.Entity = value;
					if ((value != null))
					{
						value.Adjustments.Add(this);
						this._CharacterId = value.Id;
					}
					else
					{
						this._CharacterId = default(int);
					}
					this.SendPropertyChanged("Character");
				}
			}
		}
		
		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._Token = default(EntityRef<Token>);
			this._Character = default(EntityRef<Character>);
			OnCreated();
		}
		
		[OnDeserializing()]
		[System.ComponentModel.EditorBrowsableAttribute(EditorBrowsableState.Never)]
		public void OnDeserializing(StreamingContext context)
		{
			this.Initialize();
		}
	}
	
	[Table(Name="dbo.Attendees")]
	[DataContract()]
	public partial class Attendee : INotifyPropertyChanging, INotifyPropertyChanged
	{
		
		private static PropertyChangingEventArgs emptyChangingEventArgs = new PropertyChangingEventArgs(String.Empty);
		
		private int _Id;
		
		private int _RosterId;
		
		private int _CharacterId;
		
		private EntityRef<Character> _Character;
		
		private EntityRef<Roster> _Roster;
		
    #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 OnRosterIdChanging(int value);
    partial void OnRosterIdChanged();
    partial void OnCharacterIdChanging(int value);
    partial void OnCharacterIdChanged();
    #endregion
		
		public Attendee()
		{
			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="_RosterId", DbType="Int NOT NULL")]
		[DataMember(Order=2)]
		public int RosterId
		{
			get
			{
				return this._RosterId;
			}
			set
			{
				if ((this._RosterId != value))
				{
					if (this._Roster.HasLoadedOrAssignedValue)
					{
						throw new System.Data.Linq.ForeignKeyReferenceAlreadyHasValueException();
					}
					this.OnRosterIdChanging(value);
					this.SendPropertyChanging();
					this._RosterId = value;
					this.SendPropertyChanged("RosterId");
					this.OnRosterIdChanged();
				}
			}
		}
		
		[Column(Storage="_CharacterId", DbType="Int NOT NULL")]
		[DataMember(Order=3)]
		public int CharacterId
		{
			get
			{
				return this._CharacterId;
			}
			set
			{
				if ((this._CharacterId != value))
				{
					if (this._Character.HasLoadedOrAssignedValue)
					{
						throw new System.Data.Linq.ForeignKeyReferenceAlreadyHasValueException();
					}
					this.OnCharacterIdChanging(value);
					this.SendPropertyChanging();
					this._CharacterId = value;
					this.SendPropertyChanged("CharacterId");
					this.OnCharacterIdChanged();
				}
			}
		}
		
		[Association(Name="Character_Attendee", Storage="_Character", ThisKey="CharacterId", OtherKey="Id", IsForeignKey=true)]
		public Character Character
		{
			get
			{
				return this._Character.Entity;
			}
			set
			{
				Character previousValue = this._Character.Entity;
				if (((previousValue != value) 
							|| (this._Character.HasLoadedOrAssignedValue == false)))
				{
					this.SendPropertyChanging();
					if ((previousValue != null))
					{
						this._Character.Entity = null;
						previousValue.Attendees.Remove(this);
					}
					this._Character.Entity = value;
					if ((value != null))
					{
						value.Attendees.Add(this);
						this._CharacterId = value.Id;
					}
					else
					{
						this._CharacterId = default(int);
					}
					this.SendPropertyChanged("Character");
				}
			}
		}
		
		[Association(Name="Roster_Attendee", Storage="_Roster", ThisKey="RosterId", OtherKey="Id", IsForeignKey=true)]
		public Roster Roster
		{
			get
			{
				return this._Roster.Entity;
			}
			set
			{
				Roster previousValue = this._Roster.Entity;
				if (((previousValue != value) 
							|| (this._Roster.HasLoadedOrAssignedValue == false)))
				{
					this.SendPropertyChanging();
					if ((previousValue != null))
					{
						this._Roster.Entity = null;
						previousValue.Attendees.Remove(this);
					}
					this._Roster.Entity = value;
					if ((value != null))
					{
						value.Attendees.Add(this);
						this._RosterId = value.Id;
					}
					else
					{
						this._RosterId = default(int);
					}
					this.SendPropertyChanged("Roster");
				}
			}
		}
		
		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._Character = default(EntityRef<Character>);
			this._Roster = default(EntityRef<Roster>);
			OnCreated();
		}
		
		[OnDeserializing()]
		[System.ComponentModel.EditorBrowsableAttribute(EditorBrowsableState.Never)]
		public void OnDeserializing(StreamingContext context)
		{
			this.Initialize();
		}
	}
	
	[Table(Name="dbo.Characters")]
	[DataContract()]
	public partial class Character : INotifyPropertyChanging, INotifyPropertyChanged
	{
		
		private static PropertyChangingEventArgs emptyChangingEventArgs = new PropertyChangingEventArgs(String.Empty);
		
		private int _Id;
		
		private string _Name;
		
		private int _TeamId;
		
		private EntitySet<Adjustment> _Adjustments;
		
		private EntitySet<Attendee> _Attendees;
		
		private EntitySet<Key> _Keys;
		
		private EntitySet<Reward> _Rewards;
		
		private EntitySet<Tag> _Tags;
		
		private EntitySet<Timecard> _Timecards;
		
		private EntityRef<Team> _Team;
		
		private bool serializing;
		
    #region Extensibility Method Definitions
    partial void OnLoaded();
    partial void OnValidate(System.Data.Linq.ChangeAction action);
    partial void OnCreated();
    partial void OnIdChanging(int value);
    partial void OnIdChanged();
    partial void OnNameChanging(string value);
    partial void OnNameChanged();
    partial void OnTeamIdChanging(int value);
    partial void OnTeamIdChanged();
    #endregion
		
		public Character()
		{
			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="_Name", DbType="NVarChar(32) NOT NULL", CanBeNull=false)]
		[DataMember(Order=2)]
		public string Name
		{
			get
			{
				return this._Name;
			}
			set
			{
				if ((this._Name != value))
				{
					this.OnNameChanging(value);
					this.SendPropertyChanging();
					this._Name = value;
					this.SendPropertyChanged("Name");
					this.OnNameChanged();
				}
			}
		}
		
		[Column(Storage="_TeamId", DbType="Int NOT NULL")]
		[DataMember(Order=3)]
		public int TeamId
		{
			get
			{
				return this._TeamId;
			}
			set
			{
				if ((this._TeamId != value))
				{
					if (this._Team.HasLoadedOrAssignedValue)
					{
						throw new System.Data.Linq.ForeignKeyReferenceAlreadyHasValueException();
					}
					this.OnTeamIdChanging(value);
					this.SendPropertyChanging();
					this._TeamId = value;
					this.SendPropertyChanged("TeamId");
					this.OnTeamIdChanged();
				}
			}
		}
		
		[Association(Name="Character_Adjustment", Storage="_Adjustments", ThisKey="Id", OtherKey="CharacterId")]
		[DataMember(Order=4, EmitDefaultValue=false)]
		public EntitySet<Adjustment> Adjustments
		{
			get
			{
				if ((this.serializing 
							&& (this._Adjustments.HasLoadedOrAssignedValues == false)))
				{
					return null;
				}
				return this._Adjustments;
			}
			set
			{
				this._Adjustments.Assign(value);
			}
		}
		
		[Association(Name="Character_Attendee", Storage="_Attendees", ThisKey="Id", OtherKey="CharacterId")]
		[DataMember(Order=5, EmitDefaultValue=false)]
		public EntitySet<Attendee> Attendees
		{
			get
			{
				if ((this.serializing 
							&& (this._Attendees.HasLoadedOrAssignedValues == false)))
				{
					return null;
				}
				return this._Attendees;
			}
			set
			{
				this._Attendees.Assign(value);
			}
		}
		
		[Association(Name="Character_Key", Storage="_Keys", ThisKey="Id", OtherKey="CharacterId")]
		[DataMember(Order=6, EmitDefaultValue=false)]
		public EntitySet<Key> Keys
		{
			get
			{
				if ((this.serializing 
							&& (this._Keys.HasLoadedOrAssignedValues == false)))
				{
					return null;
				}
				return this._Keys;
			}
			set
			{
				this._Keys.Assign(value);
			}
		}
		
		[Association(Name="Character_Reward", Storage="_Rewards", ThisKey="Id", OtherKey="CharacterId")]
		[DataMember(Order=7, EmitDefaultValue=false)]
		public EntitySet<Reward> Rewards
		{
			get
			{
				if ((this.serializing 
							&& (this._Rewards.HasLoadedOrAssignedValues == false)))
				{
					return null;
				}
				return this._Rewards;
			}
			set
			{
				this._Rewards.Assign(value);
			}
		}
		
		[Association(Name="Character_Tag", Storage="_Tags", ThisKey="Id", OtherKey="CharacterId")]
		[DataMember(Order=8, EmitDefaultValue=false)]
		public EntitySet<Tag> Tags
		{
			get
			{
				if ((this.serializing 
							&& (this._Tags.HasLoadedOrAssignedValues == false)))
				{
					return null;
				}
				return this._Tags;
			}
			set
			{
				this._Tags.Assign(value);
			}
		}
		
		[Association(Name="Character_Timecard", Storage="_Timecards", ThisKey="Id", OtherKey="CharacterId")]
		[DataMember(Order=9, EmitDefaultValue=false)]
		public EntitySet<Timecard> Timecards
		{
			get
			{
				if ((this.serializing 
							&& (this._Timecards.HasLoadedOrAssignedValues == false)))
				{
					return null;
				}
				return this._Timecards;
			}
			set
			{
				this._Timecards.Assign(value);
			}
		}
		
		[Association(Name="Team_Character", Storage="_Team", ThisKey="TeamId", OtherKey="Id", IsForeignKey=true)]
		public Team Team
		{
			get
			{
				return this._Team.Entity;
			}
			set
			{
				Team previousValue = this._Team.Entity;
				if (((previousValue != value) 
							|| (this._Team.HasLoadedOrAssignedValue == false)))
				{
					this.SendPropertyChanging();
					if ((previousValue != null))
					{
						this._Team.Entity = null;
						previousValue.Characters.Remove(this);
					}
					this._Team.Entity = value;
					if ((value != null))
					{
						value.Characters.Add(this);
						this._TeamId = value.Id;
					}
					else
					{
						this._TeamId = default(int);
					}
					this.SendPropertyChanged("Team");
				}
			}
		}
		
		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_Adjustments(Adjustment entity)
		{
			this.SendPropertyChanging();
			entity.Character = this;
		}
		
		private void detach_Adjustments(Adjustment entity)
		{
			this.SendPropertyChanging();
			entity.Character = null;
		}
		
		private void attach_Attendees(Attendee entity)
		{
			this.SendPropertyChanging();
			entity.Character = this;
		}
		
		private void detach_Attendees(Attendee entity)
		{
			this.SendPropertyChanging();
			entity.Character = null;
		}
		
		private void attach_Keys(Key entity)
		{
			this.SendPropertyChanging();
			entity.Character = this;
		}
		
		private void detach_Keys(Key entity)
		{
			this.SendPropertyChanging();
			entity.Character = null;
		}
		
		private void attach_Rewards(Reward entity)
		{
			this.SendPropertyChanging();
			entity.Character = this;
		}
		
		private void detach_Rewards(Reward entity)
		{
			this.SendPropertyChanging();
			entity.Character = null;
		}
		
		private void attach_Tags(Tag entity)
		{
			this.SendPropertyChanging();
			entity.Character = this;
		}
		
		private void detach_Tags(Tag entity)
		{
			this.SendPropertyChanging();
			entity.Character = null;
		}
		
		private void attach_Timecards(Timecard entity)
		{
			this.SendPropertyChanging();
			entity.Character = this;
		}
		
		private void detach_Timecards(Timecard entity)
		{
			this.SendPropertyChanging();
			entity.Character = null;
		}
		
		private void Initialize()
		{
			this._Adjustments = new EntitySet<Adjustment>(new Action<Adjustment>(this.attach_Adjustments), new Action<Adjustment>(this.detach_Adjustments));
			this._Attendees = new EntitySet<Attendee>(new Action<Attendee>(this.attach_Attendees), new Action<Attendee>(this.detach_Attendees));
			this._Keys = new EntitySet<Key>(new Action<Key>(this.attach_Keys), new Action<Key>(this.detach_Keys));
			this._Rewards = new EntitySet<Reward>(new Action<Reward>(this.attach_Rewards), new Action<Reward>(this.detach_Rewards));
			this._Tags = new EntitySet<Tag>(new Action<Tag>(this.attach_Tags), new Action<Tag>(this.detach_Tags));
			this._Timecards = new EntitySet<Timecard>(new Action<Timecard>(this.attach_Timecards), new Action<Timecard>(this.detach_Timecards));
			this._Team = default(EntityRef<Team>);
			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.Elements")]
	[DataContract()]
	public partial class Element : INotifyPropertyChanging, INotifyPropertyChanged
	{
		
		private static PropertyChangingEventArgs emptyChangingEventArgs = new PropertyChangingEventArgs(String.Empty);
		
		private int _Id;
		
		private string _Name;
		
		private EntitySet<Key> _Keys;
		
		private EntitySet<Tag> _Tags;
		
		private bool serializing;
		
    #region Extensibility Method Definitions
    partial void OnLoaded();
    partial void OnValidate(System.Data.Linq.ChangeAction action);
    partial void OnCreated();
    partial void OnIdChanging(int value);
    partial void OnIdChanged();
    partial void OnNameChanging(string value);
    partial void OnNameChanged();
    #endregion
		
		public Element()
		{
			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="_Name", DbType="NVarChar(64) NOT NULL", CanBeNull=false)]
		[DataMember(Order=2)]
		public string Name
		{
			get
			{
				return this._Name;
			}
			set
			{
				if ((this._Name != value))
				{
					this.OnNameChanging(value);
					this.SendPropertyChanging();
					this._Name = value;
					this.SendPropertyChanged("Name");
					this.OnNameChanged();
				}
			}
		}
		
		[Association(Name="Element_Key", Storage="_Keys", ThisKey="Id", OtherKey="ElementId")]
		[DataMember(Order=3, EmitDefaultValue=false)]
		public EntitySet<Key> Keys
		{
			get
			{
				if ((this.serializing 
							&& (this._Keys.HasLoadedOrAssignedValues == false)))
				{
					return null;
				}
				return this._Keys;
			}
			set
			{
				this._Keys.Assign(value);
			}
		}
		
		[Association(Name="Element_Tag", Storage="_Tags", ThisKey="Id", OtherKey="ElementId")]
		[DataMember(Order=4, EmitDefaultValue=false)]
		public EntitySet<Tag> Tags
		{
			get
			{
				if ((this.serializing 
							&& (this._Tags.HasLoadedOrAssignedValues == false)))
				{
					return null;
				}
				return this._Tags;
			}
			set
			{
				this._Tags.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_Keys(Key entity)
		{
			this.SendPropertyChanging();
			entity.Element = this;
		}
		
		private void detach_Keys(Key entity)
		{
			this.SendPropertyChanging();
			entity.Element = null;
		}
		
		private void attach_Tags(Tag entity)
		{
			this.SendPropertyChanging();
			entity.Element = this;
		}
		
		private void detach_Tags(Tag entity)
		{
			this.SendPropertyChanging();
			entity.Element = null;
		}
		
		private void Initialize()
		{
			this._Keys = new EntitySet<Key>(new Action<Key>(this.attach_Keys), new Action<Key>(this.detach_Keys));
			this._Tags = new EntitySet<Tag>(new Action<Tag>(this.attach_Tags), new Action<Tag>(this.detach_Tags));
			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.Events")]
	[DataContract()]
	public partial class Event : INotifyPropertyChanging, INotifyPropertyChanged
	{
		
		private static PropertyChangingEventArgs emptyChangingEventArgs = new PropertyChangingEventArgs(String.Empty);
		
		private int _Id;
		
		private string _Name;
		
		private EntitySet<Roster> _Rosters;
		
		private bool serializing;
		
    #region Extensibility Method Definitions
    partial void OnLoaded();
    partial void OnValidate(System.Data.Linq.ChangeAction action);
    partial void OnCreated();
    partial void OnIdChanging(int value);
    partial void OnIdChanged();
    partial void OnNameChanging(string value);
    partial void OnNameChanged();
    #endregion
		
		public Event()
		{
			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="_Name", DbType="NVarChar(64) NOT NULL", CanBeNull=false)]
		[DataMember(Order=2)]
		public string Name
		{
			get
			{
				return this._Name;
			}
			set
			{
				if ((this._Name != value))
				{
					this.OnNameChanging(value);
					this.SendPropertyChanging();
					this._Name = value;
					this.SendPropertyChanged("Name");
					this.OnNameChanged();
				}
			}
		}
		
		[Association(Name="Event_Roster", Storage="_Rosters", ThisKey="Id", OtherKey="EventId")]
		[DataMember(Order=3, EmitDefaultValue=false)]
		public EntitySet<Roster> Rosters
		{
			get
			{
				if ((this.serializing 
							&& (this._Rosters.HasLoadedOrAssignedValues == false)))
				{
					return null;
				}
				return this._Rosters;
			}
			set
			{
				this._Rosters.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_Rosters(Roster entity)
		{
			this.SendPropertyChanging();
			entity.Event = this;
		}
		
		private void detach_Rosters(Roster entity)
		{
			this.SendPropertyChanging();
			entity.Event = null;
		}
		
		private void Initialize()
		{
			this._Rosters = new EntitySet<Roster>(new Action<Roster>(this.attach_Rosters), new Action<Roster>(this.detach_Rosters));
			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.Groups")]
	[DataContract()]
	public partial class Group : INotifyPropertyChanging, INotifyPropertyChanged
	{
		
		private static PropertyChangingEventArgs emptyChangingEventArgs = new PropertyChangingEventArgs(String.Empty);
		
		private int _Id;
		
		private int _MemberId;
		
		private int _RoleId;
		
		private EntityRef<Member> _Member;
		
		private EntityRef<Role> _Role;
		
    #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 OnMemberIdChanging(int value);
    partial void OnMemberIdChanged();
    partial void OnRoleIdChanging(int value);
    partial void OnRoleIdChanged();
    #endregion
		
		public Group()
		{
			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="_MemberId", DbType="Int NOT NULL")]
		[DataMember(Order=2)]
		public int MemberId
		{
			get
			{
				return this._MemberId;
			}
			set
			{
				if ((this._MemberId != value))
				{
					if (this._Member.HasLoadedOrAssignedValue)
					{
						throw new System.Data.Linq.ForeignKeyReferenceAlreadyHasValueException();
					}
					this.OnMemberIdChanging(value);
					this.SendPropertyChanging();
					this._MemberId = value;
					this.SendPropertyChanged("MemberId");
					this.OnMemberIdChanged();
				}
			}
		}
		
		[Column(Storage="_RoleId", DbType="Int NOT NULL")]
		[DataMember(Order=3)]
		public int RoleId
		{
			get
			{
				return this._RoleId;
			}
			set
			{
				if ((this._RoleId != value))
				{
					if (this._Role.HasLoadedOrAssignedValue)
					{
						throw new System.Data.Linq.ForeignKeyReferenceAlreadyHasValueException();
					}
					this.OnRoleIdChanging(value);
					this.SendPropertyChanging();
					this._RoleId = value;
					this.SendPropertyChanged("RoleId");
					this.OnRoleIdChanged();
				}
			}
		}
		
		[Association(Name="Member_Group", Storage="_Member", ThisKey="MemberId", OtherKey="Id", IsForeignKey=true)]
		public Member Member
		{
			get
			{
				return this._Member.Entity;
			}
			set
			{
				Member previousValue = this._Member.Entity;
				if (((previousValue != value) 
							|| (this._Member.HasLoadedOrAssignedValue == false)))
				{
					this.SendPropertyChanging();
					if ((previousValue != null))
					{
						this._Member.Entity = null;
						previousValue.Groups.Remove(this);
					}
					this._Member.Entity = value;
					if ((value != null))
					{
						value.Groups.Add(this);
						this._MemberId = value.Id;
					}
					else
					{
						this._MemberId = default(int);
					}
					this.SendPropertyChanged("Member");
				}
			}
		}
		
		[Association(Name="Role_Group", Storage="_Role", ThisKey="RoleId", OtherKey="Id", IsForeignKey=true)]
		public Role Role
		{
			get
			{
				return this._Role.Entity;
			}
			set
			{
				Role previousValue = this._Role.Entity;
				if (((previousValue != value) 
							|| (this._Role.HasLoadedOrAssignedValue == false)))
				{
					this.SendPropertyChanging();
					if ((previousValue != null))
					{
						this._Role.Entity = null;
						previousValue.Groups.Remove(this);
					}
					this._Role.Entity = value;
					if ((value != null))
					{
						value.Groups.Add(this);
						this._RoleId = value.Id;
					}
					else
					{
						this._RoleId = default(int);
					}
					this.SendPropertyChanged("Role");
				}
			}
		}
		
		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._Member = default(EntityRef<Member>);
			this._Role = default(EntityRef<Role>);
			OnCreated();
		}
		
		[OnDeserializing()]
		[System.ComponentModel.EditorBrowsableAttribute(EditorBrowsableState.Never)]
		public void OnDeserializing(StreamingContext context)
		{
			this.Initialize();
		}
	}
	
	[Table(Name="dbo.Keys")]
	[DataContract()]
	public partial class Key : INotifyPropertyChanging, INotifyPropertyChanged
	{
		
		private static PropertyChangingEventArgs emptyChangingEventArgs = new PropertyChangingEventArgs(String.Empty);
		
		private int _Id;
		
		private string _Value;
		
		private int _CharacterId;
		
		private int _ElementId;
		
		private EntitySet<Pair> _Pairs;
		
		private EntityRef<Character> _Character;
		
		private EntityRef<Element> _Element;
		
		private bool serializing;
		
    #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 OnValueChanging(string value);
    partial void OnValueChanged();
    partial void OnCharacterIdChanging(int value);
    partial void OnCharacterIdChanged();
    partial void OnElementIdChanging(int value);
    partial void OnElementIdChanged();
    #endregion
		
		public Key()
		{
			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="_Value", DbType="NVarChar(128) NOT NULL", CanBeNull=false)]
		[DataMember(Order=2)]
		public string Value
		{
			get
			{
				return this._Value;
			}
			set
			{
				if ((this._Value != value))
				{
					this.OnValueChanging(value);
					this.SendPropertyChanging();
					this._Value = value;
					this.SendPropertyChanged("Value");
					this.OnValueChanged();
				}
			}
		}
		
		[Column(Storage="_CharacterId", DbType="Int NOT NULL")]
		[DataMember(Order=3)]
		public int CharacterId
		{
			get
			{
				return this._CharacterId;
			}
			set
			{
				if ((this._CharacterId != value))
				{
					if (this._Character.HasLoadedOrAssignedValue)
					{
						throw new System.Data.Linq.ForeignKeyReferenceAlreadyHasValueException();
					}
					this.OnCharacterIdChanging(value);
					this.SendPropertyChanging();
					this._CharacterId = value;
					this.SendPropertyChanged("CharacterId");
					this.OnCharacterIdChanged();
				}
			}
		}
		
		[Column(Storage="_ElementId", DbType="Int NOT NULL")]
		[DataMember(Order=4)]
		public int ElementId
		{
			get
			{
				return this._ElementId;
			}
			set
			{
				if ((this._ElementId != value))
				{
					if (this._Element.HasLoadedOrAssignedValue)
					{
						throw new System.Data.Linq.ForeignKeyReferenceAlreadyHasValueException();
					}
					this.OnElementIdChanging(value);
					this.SendPropertyChanging();
					this._ElementId = value;
					this.SendPropertyChanged("ElementId");
					this.OnElementIdChanged();
				}
			}
		}
 
		[Association(Name="Key_Pair", Storage="_Pairs", ThisKey="Id", OtherKey="KeyId")]
		[DataMember(Order=5, EmitDefaultValue=false)]
		public EntitySet<Pair> Pairs
		{
			get
			{
				if ((this.serializing 
							&& (this._Pairs.HasLoadedOrAssignedValues == false)))
				{
					return null;
				}
				return this._Pairs;
			}
			set
			{
				this._Pairs.Assign(value);
			}
		}
		
		[Association(Name="Character_Key", Storage="_Character", ThisKey="CharacterId", OtherKey="Id", IsForeignKey=true)]
		public Character Character
		{
			get
			{
				return this._Character.Entity;
			}
			set
			{
				Character previousValue = this._Character.Entity;
				if (((previousValue != value) 
							|| (this._Character.HasLoadedOrAssignedValue == false)))
				{
					this.SendPropertyChanging();
					if ((previousValue != null))
					{
						this._Character.Entity = null;
						previousValue.Keys.Remove(this);
					}
					this._Character.Entity = value;
					if ((value != null))
					{
						value.Keys.Add(this);
						this._CharacterId = value.Id;
					}
					else
					{
						this._CharacterId = default(int);
					}
					this.SendPropertyChanged("Character");
				}
			}
		}
		
		[Association(Name="Element_Key", Storage="_Element", ThisKey="ElementId", OtherKey="Id", IsForeignKey=true)]
		public Element Element
		{
			get
			{
				return this._Element.Entity;
			}
			set
			{
				Element previousValue = this._Element.Entity;
				if (((previousValue != value) 
							|| (this._Element.HasLoadedOrAssignedValue == false)))
				{
					this.SendPropertyChanging();
					if ((previousValue != null))
					{
						this._Element.Entity = null;
						previousValue.Keys.Remove(this);
					}
					this._Element.Entity = value;
					if ((value != null))
					{
						value.Keys.Add(this);
						this._ElementId = value.Id;
					}
					else
					{
						this._ElementId = default(int);
					}
					this.SendPropertyChanged("Element");
				}
			}
		}
		
		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_Pairs(Pair entity)
		{
			this.SendPropertyChanging();
			entity.Key = this;
		}
		
		private void detach_Pairs(Pair entity)
		{
			this.SendPropertyChanging();
			entity.Key = null;
		}
		
		private void Initialize()
		{
			this._Pairs = new EntitySet<Pair>(new Action<Pair>(this.attach_Pairs), new Action<Pair>(this.detach_Pairs));
			this._Character = default(EntityRef<Character>);
			this._Element = default(EntityRef<Element>);
			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.Logs")]
	[DataContract()]
	public partial class Log : INotifyPropertyChanging, INotifyPropertyChanged
	{
		
		private static PropertyChangingEventArgs emptyChangingEventArgs = new PropertyChangingEventArgs(String.Empty);
		
		private int _Id;
		
		private int _MemberId;
		
		private System.DateTime _Timestamp;
		
		private EntityRef<Member> _Member;
		
    #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 OnMemberIdChanging(int value);
    partial void OnMemberIdChanged();
    partial void OnTimestampChanging(System.DateTime value);
    partial void OnTimestampChanged();
    #endregion
		
		public Log()
		{
			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="_MemberId", DbType="Int NOT NULL")]
		[DataMember(Order=2)]
		public int MemberId
		{
			get
			{
				return this._MemberId;
			}
			set
			{
				if ((this._MemberId != value))
				{
					if (this._Member.HasLoadedOrAssignedValue)
					{
						throw new System.Data.Linq.ForeignKeyReferenceAlreadyHasValueException();
					}
					this.OnMemberIdChanging(value);
					this.SendPropertyChanging();
					this._MemberId = value;
					this.SendPropertyChanged("MemberId");
					this.OnMemberIdChanged();
				}
			}
		}
		
		[Column(Storage="_Timestamp", DbType="Date NOT NULL")]
		[DataMember(Order=3)]
		public System.DateTime Timestamp
		{
			get
			{
				return this._Timestamp;
			}
			set
			{
				if ((this._Timestamp != value))
				{
					this.OnTimestampChanging(value);
					this.SendPropertyChanging();
					this._Timestamp = value;
					this.SendPropertyChanged("Timestamp");
					this.OnTimestampChanged();
				}
			}
		}
		
		[Association(Name="Member_Log", Storage="_Member", ThisKey="MemberId", OtherKey="Id", IsForeignKey=true)]
		public Member Member
		{
			get
			{
				return this._Member.Entity;
			}
			set
			{
				Member previousValue = this._Member.Entity;
				if (((previousValue != value) 
							|| (this._Member.HasLoadedOrAssignedValue == false)))
				{
					this.SendPropertyChanging();
					if ((previousValue != null))
					{
						this._Member.Entity = null;
						previousValue.Logs.Remove(this);
					}
					this._Member.Entity = value;
					if ((value != null))
					{
						value.Logs.Add(this);
						this._MemberId = value.Id;
					}
					else
					{
						this._MemberId = default(int);
					}
					this.SendPropertyChanged("Member");
				}
			}
		}
		
		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._Member = default(EntityRef<Member>);
			OnCreated();
		}
		
		[OnDeserializing()]
		[System.ComponentModel.EditorBrowsableAttribute(EditorBrowsableState.Never)]
		public void OnDeserializing(StreamingContext context)
		{
			this.Initialize();
		}
	}
	
	[Table(Name="dbo.Measures")]
	[DataContract()]
	public partial class Measure : INotifyPropertyChanging, INotifyPropertyChanged
	{
		
		private static PropertyChangingEventArgs emptyChangingEventArgs = new PropertyChangingEventArgs(String.Empty);
		
		private int _Id;
		
		private string _Name;
		
    #region Extensibility Method Definitions
    partial void OnLoaded();
    partial void OnValidate(System.Data.Linq.ChangeAction action);
    partial void OnCreated();
    partial void OnIdChanging(int value);
    partial void OnIdChanged();
    partial void OnNameChanging(string value);
    partial void OnNameChanged();
    #endregion
		
		public Measure()
		{
			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="_Name", DbType="NVarChar(24) NOT NULL", CanBeNull=false)]
		[DataMember(Order=2)]
		public string Name
		{
			get
			{
				return this._Name;
			}
			set
			{
				if ((this._Name != value))
				{
					this.OnNameChanging(value);
					this.SendPropertyChanging();
					this._Name = value;
					this.SendPropertyChanged("Name");
					this.OnNameChanged();
				}
			}
		}
		
		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.Members")]
	[DataContract()]
	public partial class Member : INotifyPropertyChanging, INotifyPropertyChanged
	{
		
		private static PropertyChangingEventArgs emptyChangingEventArgs = new PropertyChangingEventArgs(String.Empty);
		
		private int _Id;
		
		private string _Name;
		
		private EntitySet<Group> _Groups;
		
		private EntitySet<Log> _Logs;
		
		private EntitySet<Password> _Passwords;
		
		private bool serializing;
		
    #region Extensibility Method Definitions
    partial void OnLoaded();
    partial void OnValidate(System.Data.Linq.ChangeAction action);
    partial void OnCreated();
    partial void OnIdChanging(int value);
    partial void OnIdChanged();
    partial void OnNameChanging(string value);
    partial void OnNameChanged();
    #endregion
		
		public Member()
		{
			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="_Name", DbType="NVarChar(32) NOT NULL", CanBeNull=false)]
		[DataMember(Order=2)]
		public string Name
		{
			get
			{
				return this._Name;
			}
			set
			{
				if ((this._Name != value))
				{
					this.OnNameChanging(value);
					this.SendPropertyChanging();
					this._Name = value;
					this.SendPropertyChanged("Name");
					this.OnNameChanged();
				}
			}
		}
		
		[Association(Name="Member_Group", Storage="_Groups", ThisKey="Id", OtherKey="MemberId")]
		[DataMember(Order=3, EmitDefaultValue=false)]
		public EntitySet<Group> Groups
		{
			get
			{
				if ((this.serializing 
							&& (this._Groups.HasLoadedOrAssignedValues == false)))
				{
					return null;
				}
				return this._Groups;
			}
			set
			{
				this._Groups.Assign(value);
			}
		}
		
		[Association(Name="Member_Log", Storage="_Logs", ThisKey="Id", OtherKey="MemberId")]
		[DataMember(Order=4, EmitDefaultValue=false)]
		public EntitySet<Log> Logs
		{
			get
			{
				if ((this.serializing 
							&& (this._Logs.HasLoadedOrAssignedValues == false)))
				{
					return null;
				}
				return this._Logs;
			}
			set
			{
				this._Logs.Assign(value);
			}
		}
		
		[Association(Name="Member_Password", Storage="_Passwords", ThisKey="Id", OtherKey="MemberId")]
		[DataMember(Order=5, EmitDefaultValue=false)]
		public EntitySet<Password> Passwords
		{
			get
			{
				if ((this.serializing 
							&& (this._Passwords.HasLoadedOrAssignedValues == false)))
				{
					return null;
				}
				return this._Passwords;
			}
			set
			{
				this._Passwords.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_Groups(Group entity)
		{
			this.SendPropertyChanging();
			entity.Member = this;
		}
		
		private void detach_Groups(Group entity)
		{
			this.SendPropertyChanging();
			entity.Member = null;
		}
		
		private void attach_Logs(Log entity)
		{
			this.SendPropertyChanging();
			entity.Member = this;
		}
		
		private void detach_Logs(Log entity)
		{
			this.SendPropertyChanging();
			entity.Member = null;
		}
		
		private void attach_Passwords(Password entity)
		{
			this.SendPropertyChanging();
			entity.Member = this;
		}
		
		private void detach_Passwords(Password entity)
		{
			this.SendPropertyChanging();
			entity.Member = null;
		}
		
		private void Initialize()
		{
			this._Groups = new EntitySet<Group>(new Action<Group>(this.attach_Groups), new Action<Group>(this.detach_Groups));
			this._Logs = new EntitySet<Log>(new Action<Log>(this.attach_Logs), new Action<Log>(this.detach_Logs));
			this._Passwords = new EntitySet<Password>(new Action<Password>(this.attach_Passwords), new Action<Password>(this.detach_Passwords));
			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.Pairs")]
	[DataContract()]
	public partial class Pair : INotifyPropertyChanging, INotifyPropertyChanged
	{
		
		private static PropertyChangingEventArgs emptyChangingEventArgs = new PropertyChangingEventArgs(String.Empty);
		
		private int _Id;
		
		private int _KeyId;
		
		private string _Value;
		
		private EntityRef<Key> _Key;
		
    #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 OnKeyIdChanging(int value);
    partial void OnKeyIdChanged();
    partial void OnValueChanging(string value);
    partial void OnValueChanged();
    #endregion
		
		public Pair()
		{
			this.Initialize();
		}
		
		[Column(Storage="_Id", DbType="Int NOT NULL", IsPrimaryKey=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="_KeyId", DbType="Int NOT NULL")]
		[DataMember(Order=2)]
		public int KeyId
		{
			get
			{
				return this._KeyId;
			}
			set
			{
				if ((this._KeyId != value))
				{
					if (this._Key.HasLoadedOrAssignedValue)
					{
						throw new System.Data.Linq.ForeignKeyReferenceAlreadyHasValueException();
					}
					this.OnKeyIdChanging(value);
					this.SendPropertyChanging();
					this._KeyId = value;
					this.SendPropertyChanged("KeyId");
					this.OnKeyIdChanged();
				}
			}
		}
		
		[Column(Storage="_Value", DbType="NVarChar(64) NOT NULL", CanBeNull=false)]
		[DataMember(Order=3)]
		public string Value
		{
			get
			{
				return this._Value;
			}
			set
			{
				if ((this._Value != value))
				{
					this.OnValueChanging(value);
					this.SendPropertyChanging();
					this._Value = value;
					this.SendPropertyChanged("Value");
					this.OnValueChanged();
				}
			}
		}
		
		[Association(Name="Key_Pair", Storage="_Key", ThisKey="KeyId", OtherKey="Id", IsForeignKey=true)]
		public Key Key
		{
			get
			{
				return this._Key.Entity;
			}
			set
			{
				Key previousValue = this._Key.Entity;
				if (((previousValue != value) 
							|| (this._Key.HasLoadedOrAssignedValue == false)))
				{
					this.SendPropertyChanging();
					if ((previousValue != null))
					{
						this._Key.Entity = null;
						previousValue.Pairs.Remove(this);
					}
					this._Key.Entity = value;
					if ((value != null))
					{
						value.Pairs.Add(this);
						this._KeyId = value.Id;
					}
					else
					{
						this._KeyId = default(int);
					}
					this.SendPropertyChanged("Key");
				}
			}
		}
		
		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._Key = default(EntityRef<Key>);
			OnCreated();
		}
		
		[OnDeserializing()]
		[System.ComponentModel.EditorBrowsableAttribute(EditorBrowsableState.Never)]
		public void OnDeserializing(StreamingContext context)
		{
			this.Initialize();
		}
	}
	
	[Table(Name="dbo.Passwords")]
	[DataContract()]
	public partial class Password : INotifyPropertyChanging, INotifyPropertyChanged
	{
		
		private static PropertyChangingEventArgs emptyChangingEventArgs = new PropertyChangingEventArgs(String.Empty);
		
		private System.Guid _Id;
		
		private string _Hash;
		
		private int _MemberId;
		
		private EntityRef<Member> _Member;
		
    #region Extensibility Method Definitions
    partial void OnLoaded();
    partial void OnValidate(System.Data.Linq.ChangeAction action);
    partial void OnCreated();
    partial void OnIdChanging(System.Guid value);
    partial void OnIdChanged();
    partial void OnHashChanging(string value);
    partial void OnHashChanged();
    partial void OnMemberIdChanging(int value);
    partial void OnMemberIdChanged();
    #endregion
		
		public Password()
		{
			this.Initialize();
		}
		
		[Column(Storage="_Id", DbType="UniqueIdentifier NOT NULL", IsPrimaryKey=true)]
		[DataMember(Order=1)]
		public System.Guid 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="_Hash", DbType="Char(128) NOT NULL", CanBeNull=false)]
		[DataMember(Order=2)]
		public string Hash
		{
			get
			{
				return this._Hash;
			}
			set
			{
				if ((this._Hash != value))
				{
					this.OnHashChanging(value);
					this.SendPropertyChanging();
					this._Hash = value;
					this.SendPropertyChanged("Hash");
					this.OnHashChanged();
				}
			}
		}
		
		[Column(Storage="_MemberId", DbType="Int NOT NULL")]
		[DataMember(Order=3)]
		public int MemberId
		{
			get
			{
				return this._MemberId;
			}
			set
			{
				if ((this._MemberId != value))
				{
					if (this._Member.HasLoadedOrAssignedValue)
					{
						throw new System.Data.Linq.ForeignKeyReferenceAlreadyHasValueException();
					}
					this.OnMemberIdChanging(value);
					this.SendPropertyChanging();
					this._MemberId = value;
					this.SendPropertyChanged("MemberId");
					this.OnMemberIdChanged();
				}
			}
		}
		
		[Association(Name="Member_Password", Storage="_Member", ThisKey="MemberId", OtherKey="Id", IsForeignKey=true)]
		public Member Member
		{
			get
			{
				return this._Member.Entity;
			}
			set
			{
				Member previousValue = this._Member.Entity;
				if (((previousValue != value) 
							|| (this._Member.HasLoadedOrAssignedValue == false)))
				{
					this.SendPropertyChanging();
					if ((previousValue != null))
					{
						this._Member.Entity = null;
						previousValue.Passwords.Remove(this);
					}
					this._Member.Entity = value;
					if ((value != null))
					{
						value.Passwords.Add(this);
						this._MemberId = value.Id;
					}
					else
					{
						this._MemberId = default(int);
					}
					this.SendPropertyChanged("Member");
				}
			}
		}
		
		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._Member = default(EntityRef<Member>);
			OnCreated();
		}
		
		[OnDeserializing()]
		[System.ComponentModel.EditorBrowsableAttribute(EditorBrowsableState.Never)]
		public void OnDeserializing(StreamingContext context)
		{
			this.Initialize();
		}
	}
	
	[Table(Name="dbo.Rewards")]
	[DataContract()]
	public partial class Reward : INotifyPropertyChanging, INotifyPropertyChanged
	{
		
		private static PropertyChangingEventArgs emptyChangingEventArgs = new PropertyChangingEventArgs(String.Empty);
		
		private int _Id;
		
		private int _CharacterId;
		
		private int _TokenId;
		
		private System.DateTime _Timestamp;
		
		private EntityRef<Character> _Character;
		
		private EntityRef<Token> _Token;
		
    #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 OnCharacterIdChanging(int value);
    partial void OnCharacterIdChanged();
    partial void OnTokenIdChanging(int value);
    partial void OnTokenIdChanged();
    partial void OnTimestampChanging(System.DateTime value);
    partial void OnTimestampChanged();
    #endregion
		
		public Reward()
		{
			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="_CharacterId", DbType="Int NOT NULL")]
		[DataMember(Order=2)]
		public int CharacterId
		{
			get
			{
				return this._CharacterId;
			}
			set
			{
				if ((this._CharacterId != value))
				{
					if (this._Character.HasLoadedOrAssignedValue)
					{
						throw new System.Data.Linq.ForeignKeyReferenceAlreadyHasValueException();
					}
					this.OnCharacterIdChanging(value);
					this.SendPropertyChanging();
					this._CharacterId = value;
					this.SendPropertyChanged("CharacterId");
					this.OnCharacterIdChanged();
				}
			}
		}
		
		[Column(Storage="_TokenId", DbType="Int NOT NULL")]
		[DataMember(Order=3)]
		public int TokenId
		{
			get
			{
				return this._TokenId;
			}
			set
			{
				if ((this._TokenId != value))
				{
					if (this._Token.HasLoadedOrAssignedValue)
					{
						throw new System.Data.Linq.ForeignKeyReferenceAlreadyHasValueException();
					}
					this.OnTokenIdChanging(value);
					this.SendPropertyChanging();
					this._TokenId = value;
					this.SendPropertyChanged("TokenId");
					this.OnTokenIdChanged();
				}
			}
		}
		
		[Column(Storage="_Timestamp", DbType="DateTime NOT NULL")]
		[DataMember(Order=4)]
		public System.DateTime Timestamp
		{
			get
			{
				return this._Timestamp;
			}
			set
			{
				if ((this._Timestamp != value))
				{
					this.OnTimestampChanging(value);
					this.SendPropertyChanging();
					this._Timestamp = value;
					this.SendPropertyChanged("Timestamp");
					this.OnTimestampChanged();
				}
			}
		}
		
		[Association(Name="Character_Reward", Storage="_Character", ThisKey="CharacterId", OtherKey="Id", IsForeignKey=true)]
		public Character Character
		{
			get
			{
				return this._Character.Entity;
			}
			set
			{
				Character previousValue = this._Character.Entity;
				if (((previousValue != value) 
							|| (this._Character.HasLoadedOrAssignedValue == false)))
				{
					this.SendPropertyChanging();
					if ((previousValue != null))
					{
						this._Character.Entity = null;
						previousValue.Rewards.Remove(this);
					}
					this._Character.Entity = value;
					if ((value != null))
					{
						value.Rewards.Add(this);
						this._CharacterId = value.Id;
					}
					else
					{
						this._CharacterId = default(int);
					}
					this.SendPropertyChanged("Character");
				}
			}
		}
		
		[Association(Name="Token_Reward", Storage="_Token", ThisKey="TokenId", OtherKey="Id", IsForeignKey=true)]
		public Token Token
		{
			get
			{
				return this._Token.Entity;
			}
			set
			{
				Token previousValue = this._Token.Entity;
				if (((previousValue != value) 
							|| (this._Token.HasLoadedOrAssignedValue == false)))
				{
					this.SendPropertyChanging();
					if ((previousValue != null))
					{
						this._Token.Entity = null;
						previousValue.Rewards.Remove(this);
					}
					this._Token.Entity = value;
					if ((value != null))
					{
						value.Rewards.Add(this);
						this._TokenId = value.Id;
					}
					else
					{
						this._TokenId = default(int);
					}
					this.SendPropertyChanged("Token");
				}
			}
		}
		
		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._Character = default(EntityRef<Character>);
			this._Token = default(EntityRef<Token>);
			OnCreated();
		}
		
		[OnDeserializing()]
		[System.ComponentModel.EditorBrowsableAttribute(EditorBrowsableState.Never)]
		public void OnDeserializing(StreamingContext context)
		{
			this.Initialize();
		}
	}
	
	[Table(Name="dbo.Roles")]
	[DataContract()]
	public partial class Role : INotifyPropertyChanging, INotifyPropertyChanged
	{
		
		private static PropertyChangingEventArgs emptyChangingEventArgs = new PropertyChangingEventArgs(String.Empty);
		
		private int _Id;
		
		private string _Name;
		
		private EntitySet<Group> _Groups;
		
		private bool serializing;
		
    #region Extensibility Method Definitions
    partial void OnLoaded();
    partial void OnValidate(System.Data.Linq.ChangeAction action);
    partial void OnCreated();
    partial void OnIdChanging(int value);
    partial void OnIdChanged();
    partial void OnNameChanging(string value);
    partial void OnNameChanged();
    #endregion
		
		public Role()
		{
			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="_Name", DbType="NVarChar(32) NOT NULL", CanBeNull=false)]
		[DataMember(Order=2)]
		public string Name
		{
			get
			{
				return this._Name;
			}
			set
			{
				if ((this._Name != value))
				{
					this.OnNameChanging(value);
					this.SendPropertyChanging();
					this._Name = value;
					this.SendPropertyChanged("Name");
					this.OnNameChanged();
				}
			}
		}
		
		[Association(Name="Role_Group", Storage="_Groups", ThisKey="Id", OtherKey="RoleId")]
		[DataMember(Order=3, EmitDefaultValue=false)]
		public EntitySet<Group> Groups
		{
			get
			{
				if ((this.serializing 
							&& (this._Groups.HasLoadedOrAssignedValues == false)))
				{
					return null;
				}
				return this._Groups;
			}
			set
			{
				this._Groups.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_Groups(Group entity)
		{
			this.SendPropertyChanging();
			entity.Role = this;
		}
		
		private void detach_Groups(Group entity)
		{
			this.SendPropertyChanging();
			entity.Role = null;
		}
		
		private void Initialize()
		{
			this._Groups = new EntitySet<Group>(new Action<Group>(this.attach_Groups), new Action<Group>(this.detach_Groups));
			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.Rosters")]
	[DataContract()]
	public partial class Roster : INotifyPropertyChanging, INotifyPropertyChanged
	{
		
		private static PropertyChangingEventArgs emptyChangingEventArgs = new PropertyChangingEventArgs(String.Empty);
		
		private int _Id;
		
		private int _EventId;
		
		private EntitySet<Achievement> _Achievements;
		
		private EntitySet<Attendee> _Attendees;
		
		private EntitySet<Timecard> _Timecards;
		
		private EntityRef<Event> _Event;
		
		private bool serializing;
		
    #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 OnEventIdChanging(int value);
    partial void OnEventIdChanged();
    #endregion
		
		public Roster()
		{
			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="_EventId", DbType="Int NOT NULL")]
		[DataMember(Order=2)]
		public int EventId
		{
			get
			{
				return this._EventId;
			}
			set
			{
				if ((this._EventId != value))
				{
					if (this._Event.HasLoadedOrAssignedValue)
					{
						throw new System.Data.Linq.ForeignKeyReferenceAlreadyHasValueException();
					}
					this.OnEventIdChanging(value);
					this.SendPropertyChanging();
					this._EventId = value;
					this.SendPropertyChanged("EventId");
					this.OnEventIdChanged();
				}
			}
		}
		
		[Association(Name="Roster_Achievement", Storage="_Achievements", ThisKey="Id", OtherKey="RosterId")]
		[DataMember(Order=3, EmitDefaultValue=false)]
		public EntitySet<Achievement> Achievements
		{
			get
			{
				if ((this.serializing 
							&& (this._Achievements.HasLoadedOrAssignedValues == false)))
				{
					return null;
				}
				return this._Achievements;
			}
			set
			{
				this._Achievements.Assign(value);
			}
		}
		
		[Association(Name="Roster_Attendee", Storage="_Attendees", ThisKey="Id", OtherKey="RosterId")]
		[DataMember(Order=4, EmitDefaultValue=false)]
		public EntitySet<Attendee> Attendees
		{
			get
			{
				if ((this.serializing 
							&& (this._Attendees.HasLoadedOrAssignedValues == false)))
				{
					return null;
				}
				return this._Attendees;
			}
			set
			{
				this._Attendees.Assign(value);
			}
		}
		
		[Association(Name="Roster_Timecard", Storage="_Timecards", ThisKey="Id", OtherKey="RosterId")]
		[DataMember(Order=5, EmitDefaultValue=false)]
		public EntitySet<Timecard> Timecards
		{
			get
			{
				if ((this.serializing 
							&& (this._Timecards.HasLoadedOrAssignedValues == false)))
				{
					return null;
				}
				return this._Timecards;
			}
			set
			{
				this._Timecards.Assign(value);
			}
		}
		
		[Association(Name="Event_Roster", Storage="_Event", ThisKey="EventId", OtherKey="Id", IsForeignKey=true)]
		public Event Event
		{
			get
			{
				return this._Event.Entity;
			}
			set
			{
				Event previousValue = this._Event.Entity;
				if (((previousValue != value) 
							|| (this._Event.HasLoadedOrAssignedValue == false)))
				{
					this.SendPropertyChanging();
					if ((previousValue != null))
					{
						this._Event.Entity = null;
						previousValue.Rosters.Remove(this);
					}
					this._Event.Entity = value;
					if ((value != null))
					{
						value.Rosters.Add(this);
						this._EventId = value.Id;
					}
					else
					{
						this._EventId = default(int);
					}
					this.SendPropertyChanged("Event");
				}
			}
		}
		
		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_Achievements(Achievement entity)
		{
			this.SendPropertyChanging();
			entity.Roster = this;
		}
		
		private void detach_Achievements(Achievement entity)
		{
			this.SendPropertyChanging();
			entity.Roster = null;
		}
		
		private void attach_Attendees(Attendee entity)
		{
			this.SendPropertyChanging();
			entity.Roster = this;
		}
		
		private void detach_Attendees(Attendee entity)
		{
			this.SendPropertyChanging();
			entity.Roster = null;
		}
		
		private void attach_Timecards(Timecard entity)
		{
			this.SendPropertyChanging();
			entity.Roster = this;
		}
		
		private void detach_Timecards(Timecard entity)
		{
			this.SendPropertyChanging();
			entity.Roster = null;
		}
		
		private void Initialize()
		{
			this._Achievements = new EntitySet<Achievement>(new Action<Achievement>(this.attach_Achievements), new Action<Achievement>(this.detach_Achievements));
			this._Attendees = new EntitySet<Attendee>(new Action<Attendee>(this.attach_Attendees), new Action<Attendee>(this.detach_Attendees));
			this._Timecards = new EntitySet<Timecard>(new Action<Timecard>(this.attach_Timecards), new Action<Timecard>(this.detach_Timecards));
			this._Event = default(EntityRef<Event>);
			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.Rules")]
	[DataContract()]
	public partial class Rule : INotifyPropertyChanging, INotifyPropertyChanged
	{
		
		private static PropertyChangingEventArgs emptyChangingEventArgs = new PropertyChangingEventArgs(String.Empty);
		
		private int _Id;
		
		private string _Title;
		
    #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 OnTitleChanging(string value);
    partial void OnTitleChanged();
    #endregion
		
		public Rule()
		{
			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="_Title", DbType="NVarChar(64) NOT NULL", CanBeNull=false)]
		[DataMember(Order=2)]
		public string Title
		{
			get
			{
				return this._Title;
			}
			set
			{
				if ((this._Title != value))
				{
					this.OnTitleChanging(value);
					this.SendPropertyChanging();
					this._Title = value;
					this.SendPropertyChanged("Title");
					this.OnTitleChanged();
				}
			}
		}
		
		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.Tags")]
	[DataContract()]
	public partial class Tag : INotifyPropertyChanging, INotifyPropertyChanged
	{
		
		private static PropertyChangingEventArgs emptyChangingEventArgs = new PropertyChangingEventArgs(String.Empty);
		
		private int _Id;
		
		private int _CharacterId;
		
		private int _ElementId;
		
		private EntityRef<Character> _Character;
		
		private EntityRef<Element> _Element;
		
    #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 OnCharacterIdChanging(int value);
    partial void OnCharacterIdChanged();
    partial void OnElementIdChanging(int value);
    partial void OnElementIdChanged();
    #endregion
		
		public Tag()
		{
			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="_CharacterId", DbType="Int NOT NULL")]
		[DataMember(Order=2)]
		public int CharacterId
		{
			get
			{
				return this._CharacterId;
			}
			set
			{
				if ((this._CharacterId != value))
				{
					if (this._Character.HasLoadedOrAssignedValue)
					{
						throw new System.Data.Linq.ForeignKeyReferenceAlreadyHasValueException();
					}
					this.OnCharacterIdChanging(value);
					this.SendPropertyChanging();
					this._CharacterId = value;
					this.SendPropertyChanged("CharacterId");
					this.OnCharacterIdChanged();
				}
			}
		}
		
		[Column(Storage="_ElementId", DbType="Int NOT NULL")]
		[DataMember(Order=3)]
		public int ElementId
		{
			get
			{
				return this._ElementId;
			}
			set
			{
				if ((this._ElementId != value))
				{
					if (this._Element.HasLoadedOrAssignedValue)
					{
						throw new System.Data.Linq.ForeignKeyReferenceAlreadyHasValueException();
					}
					this.OnElementIdChanging(value);
					this.SendPropertyChanging();
					this._ElementId = value;
					this.SendPropertyChanged("ElementId");
					this.OnElementIdChanged();
				}
			}
		}
		
		[Association(Name="Character_Tag", Storage="_Character", ThisKey="CharacterId", OtherKey="Id", IsForeignKey=true)]
		public Character Character
		{
			get
			{
				return this._Character.Entity;
			}
			set
			{
				Character previousValue = this._Character.Entity;
				if (((previousValue != value) 
							|| (this._Character.HasLoadedOrAssignedValue == false)))
				{
					this.SendPropertyChanging();
					if ((previousValue != null))
					{
						this._Character.Entity = null;
						previousValue.Tags.Remove(this);
					}
					this._Character.Entity = value;
					if ((value != null))
					{
						value.Tags.Add(this);
						this._CharacterId = value.Id;
					}
					else
					{
						this._CharacterId = default(int);
					}
					this.SendPropertyChanged("Character");
				}
			}
		}
		
		[Association(Name="Element_Tag", Storage="_Element", ThisKey="ElementId", OtherKey="Id", IsForeignKey=true)]
		public Element Element
		{
			get
			{
				return this._Element.Entity;
			}
			set
			{
				Element previousValue = this._Element.Entity;
				if (((previousValue != value) 
							|| (this._Element.HasLoadedOrAssignedValue == false)))
				{
					this.SendPropertyChanging();
					if ((previousValue != null))
					{
						this._Element.Entity = null;
						previousValue.Tags.Remove(this);
					}
					this._Element.Entity = value;
					if ((value != null))
					{
						value.Tags.Add(this);
						this._ElementId = value.Id;
					}
					else
					{
						this._ElementId = default(int);
					}
					this.SendPropertyChanged("Element");
				}
			}
		}
		
		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._Character = default(EntityRef<Character>);
			this._Element = default(EntityRef<Element>);
			OnCreated();
		}
		
		[OnDeserializing()]
		[System.ComponentModel.EditorBrowsableAttribute(EditorBrowsableState.Never)]
		public void OnDeserializing(StreamingContext context)
		{
			this.Initialize();
		}
	}
	
	[Table(Name="dbo.Teams")]
	[DataContract()]
	public partial class Team : INotifyPropertyChanging, INotifyPropertyChanged
	{
		
		private static PropertyChangingEventArgs emptyChangingEventArgs = new PropertyChangingEventArgs(String.Empty);
		
		private int _Id;
		
		private string _Name;
		
		private EntitySet<Character> _Characters;
		
		private bool serializing;
		
    #region Extensibility Method Definitions
    partial void OnLoaded();
    partial void OnValidate(System.Data.Linq.ChangeAction action);
    partial void OnCreated();
    partial void OnIdChanging(int value);
    partial void OnIdChanged();
    partial void OnNameChanging(string value);
    partial void OnNameChanged();
    #endregion
		
		public Team()
		{
			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="_Name", DbType="NVarChar(64) NOT NULL", CanBeNull=false)]
		[DataMember(Order=2)]
		public string Name
		{
			get
			{
				return this._Name;
			}
			set
			{
				if ((this._Name != value))
				{
					this.OnNameChanging(value);
					this.SendPropertyChanging();
					this._Name = value;
					this.SendPropertyChanged("Name");
					this.OnNameChanged();
				}
			}
		}
		
		[Association(Name="Team_Character", Storage="_Characters", ThisKey="Id", OtherKey="TeamId")]
		[DataMember(Order=3, EmitDefaultValue=false)]
		public EntitySet<Character> Characters
		{
			get
			{
				if ((this.serializing 
							&& (this._Characters.HasLoadedOrAssignedValues == false)))
				{
					return null;
				}
				return this._Characters;
			}
			set
			{
				this._Characters.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_Characters(Character entity)
		{
			this.SendPropertyChanging();
			entity.Team = this;
		}
		
		private void detach_Characters(Character entity)
		{
			this.SendPropertyChanging();
			entity.Team = null;
		}
		
		private void Initialize()
		{
			this._Characters = new EntitySet<Character>(new Action<Character>(this.attach_Characters), new Action<Character>(this.detach_Characters));
			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.Timecards")]
	[DataContract()]
	public partial class Timecard : INotifyPropertyChanging, INotifyPropertyChanged
	{
		
		private static PropertyChangingEventArgs emptyChangingEventArgs = new PropertyChangingEventArgs(String.Empty);
		
		private int _Id;
		
		private int _RosterId;
		
		private int _CharacterId;
		
		private int _TimespanId;
		
		private EntityRef<Character> _Character;
		
		private EntityRef<Roster> _Roster;
		
		private EntityRef<Timespan> _Timespan;
		
    #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 OnRosterIdChanging(int value);
    partial void OnRosterIdChanged();
    partial void OnCharacterIdChanging(int value);
    partial void OnCharacterIdChanged();
    partial void OnTimespanIdChanging(int value);
    partial void OnTimespanIdChanged();
    #endregion
		
		public Timecard()
		{
			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="_RosterId", DbType="Int NOT NULL")]
		[DataMember(Order=2)]
		public int RosterId
		{
			get
			{
				return this._RosterId;
			}
			set
			{
				if ((this._RosterId != value))
				{
					if (this._Roster.HasLoadedOrAssignedValue)
					{
						throw new System.Data.Linq.ForeignKeyReferenceAlreadyHasValueException();
					}
					this.OnRosterIdChanging(value);
					this.SendPropertyChanging();
					this._RosterId = value;
					this.SendPropertyChanged("RosterId");
					this.OnRosterIdChanged();
				}
			}
		}
		
		[Column(Storage="_CharacterId", DbType="Int NOT NULL")]
		[DataMember(Order=3)]
		public int CharacterId
		{
			get
			{
				return this._CharacterId;
			}
			set
			{
				if ((this._CharacterId != value))
				{
					if (this._Character.HasLoadedOrAssignedValue)
					{
						throw new System.Data.Linq.ForeignKeyReferenceAlreadyHasValueException();
					}
					this.OnCharacterIdChanging(value);
					this.SendPropertyChanging();
					this._CharacterId = value;
					this.SendPropertyChanged("CharacterId");
					this.OnCharacterIdChanged();
				}
			}
		}
		
		[Column(Storage="_TimespanId", DbType="Int NOT NULL")]
		[DataMember(Order=4)]
		public int TimespanId
		{
			get
			{
				return this._TimespanId;
			}
			set
			{
				if ((this._TimespanId != value))
				{
					if (this._Timespan.HasLoadedOrAssignedValue)
					{
						throw new System.Data.Linq.ForeignKeyReferenceAlreadyHasValueException();
					}
					this.OnTimespanIdChanging(value);
					this.SendPropertyChanging();
					this._TimespanId = value;
					this.SendPropertyChanged("TimespanId");
					this.OnTimespanIdChanged();
				}
			}
		}
		
		[Association(Name="Character_Timecard", Storage="_Character", ThisKey="CharacterId", OtherKey="Id", IsForeignKey=true)]
		public Character Character
		{
			get
			{
				return this._Character.Entity;
			}
			set
			{
				Character previousValue = this._Character.Entity;
				if (((previousValue != value) 
							|| (this._Character.HasLoadedOrAssignedValue == false)))
				{
					this.SendPropertyChanging();
					if ((previousValue != null))
					{
						this._Character.Entity = null;
						previousValue.Timecards.Remove(this);
					}
					this._Character.Entity = value;
					if ((value != null))
					{
						value.Timecards.Add(this);
						this._CharacterId = value.Id;
					}
					else
					{
						this._CharacterId = default(int);
					}
					this.SendPropertyChanged("Character");
				}
			}
		}
		
		[Association(Name="Roster_Timecard", Storage="_Roster", ThisKey="RosterId", OtherKey="Id", IsForeignKey=true)]
		public Roster Roster
		{
			get
			{
				return this._Roster.Entity;
			}
			set
			{
				Roster previousValue = this._Roster.Entity;
				if (((previousValue != value) 
							|| (this._Roster.HasLoadedOrAssignedValue == false)))
				{
					this.SendPropertyChanging();
					if ((previousValue != null))
					{
						this._Roster.Entity = null;
						previousValue.Timecards.Remove(this);
					}
					this._Roster.Entity = value;
					if ((value != null))
					{
						value.Timecards.Add(this);
						this._RosterId = value.Id;
					}
					else
					{
						this._RosterId = default(int);
					}
					this.SendPropertyChanged("Roster");
				}
			}
		}
		
		[Association(Name="Timespan_Timecard", Storage="_Timespan", ThisKey="TimespanId", OtherKey="Id", IsForeignKey=true)]
		public Timespan Timespan
		{
			get
			{
				return this._Timespan.Entity;
			}
			set
			{
				Timespan previousValue = this._Timespan.Entity;
				if (((previousValue != value) 
							|| (this._Timespan.HasLoadedOrAssignedValue == false)))
				{
					this.SendPropertyChanging();
					if ((previousValue != null))
					{
						this._Timespan.Entity = null;
						previousValue.Timecards.Remove(this);
					}
					this._Timespan.Entity = value;
					if ((value != null))
					{
						value.Timecards.Add(this);
						this._TimespanId = value.Id;
					}
					else
					{
						this._TimespanId = default(int);
					}
					this.SendPropertyChanged("Timespan");
				}
			}
		}
		
		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._Character = default(EntityRef<Character>);
			this._Roster = default(EntityRef<Roster>);
			this._Timespan = default(EntityRef<Timespan>);
			OnCreated();
		}
		
		[OnDeserializing()]
		[System.ComponentModel.EditorBrowsableAttribute(EditorBrowsableState.Never)]
		public void OnDeserializing(StreamingContext context)
		{
			this.Initialize();
		}
	}
	
	[Table(Name="dbo.Timespans")]
	[DataContract()]
	public partial class Timespan : INotifyPropertyChanging, INotifyPropertyChanged
	{
		
		private static PropertyChangingEventArgs emptyChangingEventArgs = new PropertyChangingEventArgs(String.Empty);
		
		private int _Id;
		
		private System.DateTime _Begin;
		
		private System.DateTime _End;
		
		private EntitySet<Timecard> _Timecards;
		
		private bool serializing;
		
    #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 OnBeginChanging(System.DateTime value);
    partial void OnBeginChanged();
    partial void OnEndChanging(System.DateTime value);
    partial void OnEndChanged();
    #endregion
		
		public Timespan()
		{
			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(Name="[Begin]", Storage="_Begin", DbType="DateTime NOT NULL")]
		[DataMember(Order=2)]
		public System.DateTime Begin
		{
			get
			{
				return this._Begin;
			}
			set
			{
				if ((this._Begin != value))
				{
					this.OnBeginChanging(value);
					this.SendPropertyChanging();
					this._Begin = value;
					this.SendPropertyChanged("Begin");
					this.OnBeginChanged();
				}
			}
		}
		
		[Column(Name="[End]", Storage="_End", DbType="DateTime NOT NULL")]
		[DataMember(Order=3)]
		public System.DateTime End
		{
			get
			{
				return this._End;
			}
			set
			{
				if ((this._End != value))
				{
					this.OnEndChanging(value);
					this.SendPropertyChanging();
					this._End = value;
					this.SendPropertyChanged("End");
					this.OnEndChanged();
				}
			}
		}
		
		[Association(Name="Timespan_Timecard", Storage="_Timecards", ThisKey="Id", OtherKey="TimespanId")]
		[DataMember(Order=4, EmitDefaultValue=false)]
		public EntitySet<Timecard> Timecards
		{
			get
			{
				if ((this.serializing 
							&& (this._Timecards.HasLoadedOrAssignedValues == false)))
				{
					return null;
				}
				return this._Timecards;
			}
			set
			{
				this._Timecards.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_Timecards(Timecard entity)
		{
			this.SendPropertyChanging();
			entity.Timespan = this;
		}
		
		private void detach_Timecards(Timecard entity)
		{
			this.SendPropertyChanging();
			entity.Timespan = null;
		}
		
		private void Initialize()
		{
			this._Timecards = new EntitySet<Timecard>(new Action<Timecard>(this.attach_Timecards), new Action<Timecard>(this.detach_Timecards));
			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.Labels")]
	[DataContract()]
	public partial class Label : INotifyPropertyChanging, INotifyPropertyChanged
	{
		
		private static PropertyChangingEventArgs emptyChangingEventArgs = new PropertyChangingEventArgs(String.Empty);
		
		private int _Id;
		
		private string _Table;
		
		private string _Name;
		
    #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 OnTableChanging(string value);
    partial void OnTableChanged();
    partial void OnNameChanging(string value);
    partial void OnNameChanged();
    #endregion
		
		public Label()
		{
			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(Name="[Table]", Storage="_Table", DbType="NVarChar(128) NOT NULL", CanBeNull=false)]
		[DataMember(Order=2)]
		public string Table
		{
			get
			{
				return this._Table;
			}
			set
			{
				if ((this._Table != value))
				{
					this.OnTableChanging(value);
					this.SendPropertyChanging();
					this._Table = value;
					this.SendPropertyChanged("Table");
					this.OnTableChanged();
				}
			}
		}
		
		[Column(Storage="_Name", DbType="NVarChar(128) NOT NULL", CanBeNull=false)]
		[DataMember(Order=3)]
		public string Name
		{
			get
			{
				return this._Name;
			}
			set
			{
				if ((this._Name != value))
				{
					this.OnNameChanging(value);
					this.SendPropertyChanging();
					this._Name = value;
					this.SendPropertyChanged("Name");
					this.OnNameChanged();
				}
			}
		}
		
		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

Open in new window

The tables/classes in Question would be "Character" "Key" "Element". But this is the entire schema to give you more of an idea.
Hi veruthandai;

Linq to SQL is a way to access MS SQL server tables by way of a SQL likeish type syntax. So accessing it you will need to write a Linq query. In order to answer you question I need to know what data type is item in this statement, item.Keys[ -index can go here to get the key- ].Value the DataContext?

If item is an instance of the DataContext that you posted then no you can not use just a sting of the field name to get to the record.

Fernando
item is an instance of the Character class, which is one of the types in the database.
 
DatabaseContext.Character[0].Keys[0]
I do not know if this line of code is working in some form in your program, DatabaseContext.Character[0].Keys[0], but the DataContext class does not implement a Character method or property. The DataContext is an object that you can use to query and return result sets from a MS SQL Server database and can not be access as an array as in the above statement. If you have some working or somewhat working code that is showing what you are trying to do please post.
Try it like this...
 
Lithium.DatabaseDataContext db = new Lithium.DatabaseDataContext();
db is the datacontext that can query the mssql server.
Alright, just assume this then..
Character character = from c in db.Characters where c.Id == "1" select c;
// at this point, character.Keys[0].Value is the first key in the Keys table where CharacterId == 1.
// this would be accessed character.Keys[0].Value
// This may not always be true, but many people will have a key similar to it - but it will be at a different index in the Keys[] array. I need to figure out how to find that index per record based on the Element.Name that corrosponds to the Element.Id in the Key table.

using Lithium;
 
public class Test
{
  public void TestMethod()
  {
    DatabaseDataContext db = new DatabaseDataContext();
    Character character = new Character();
    
    character.Name = "Character1";
    
    Key newKey = new Key();
    newKey.Element = (from e in db.Elements
                       where e.Name == "Age"
                       select e).Single();
 
    newKey.Value = "25";
    character.Keys.Add(newKey);
 
    db.Characters.InsertOnSubmit(character);
    db.SubmitChanges();
 
    }
 
    public void GetData()
    {
         DatabaseDataContext db = new DatabaseDataContext();
         var character = from c in db.Characters
                         where c.Name == "Character1"
                         select c;
 
         Console.WriteLine(character.Keys[0].Value);
      }
}

Open in new window

Now this makes sense for me.
 
DatabaseContext.Character[0].Keys[0]

The simple answer to your question then is NO. There is no implementation of indexing in to a table of type System.Data.Linq.Table<TableType> which tables "Character", "Key" and "Element" are.
What situation would cause you to need that maybe I can think of another way?
So then how can I get the index I need if all I know is the string I have to search for?
The situation is that the index might not always be the same between all records. The index in the Keys array will be based on what data the user of the software puts in - it may not be "Age", it may be something completely different.
You state in your last post, "The index in the Keys array will be based on what data the user of the software puts in". When you say Keys array are you makeing reference to the database table Key or is this a true array and if it is a true array how is it involved in getting the needed data from the database?
When the user enters a key, they select a text 'name' for it - the names for keys are stored in the Elements table, then they assign it a value.
They may not always assign keys in the same order, and so they will go into the database in a different order - that is the way it is supposed to work. The keys are 'extra' data that is not 'hard coded'. They can add whatever properties to each Character that they wish.
'Keys" is a Collection generated by LINQ when I drag the tables onto the .dbml designer. This collection is a relationship of all of the Records in the "Keys" table that share the CharacterId of the current Character instance. So it is not a 'true' array - it represents the FK relationship from Keys_CharacterId to Character_Id, where as Element on the Keys object references the relationship from FK_Elements_Id to FK_Keys_ElementId.
 
To help illustrate this better I have prepared a full sample application. The database is MS-SQL Express 2008.
 
http://www.developer-network.net/LinqData.zip
Forgive me, the .zip had bad data in it. I have corrected this to illustrate better.

http://www.developer-network.net/LinqDataUpdated.zip
 
ASKER CERTIFIED SOLUTION
Avatar of Fernando Soto
Fernando Soto
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thank you!
It didn't occur to me to use the character table data to iterate with the search - I cannot believe I overlooked that.
I'm curious, you changed the database schema. What exactly did you change? I created this one in SQL server and I don't see much of a difference.
Hi veruthandai;

The difference is I remover the Primary key ID from the Keys table and used the two Foreign Keys as a composite Primary Key so that you do not create duplicates key. For example having Characters ID 1 mapped to Elements ID 1 multiple times.

Fernando
Oh!
 
Thank you very much!
Not a problem, always glad to help.  ;=)