Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version
Go to top

LINQ Challenges and SQL Server Compact Edition

, 25 Mar 2008
Overcoming challenges with LINQ to SQL and using LINQ with SQL Server Compact Edition.
#pragma warning disable 1591
//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a tool.
//     Runtime Version:2.0.50727.1433
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

namespace TimeApp.DataAccess
{
	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.ComponentModel;
	using System;
	
	
	[System.Data.Linq.Mapping.DatabaseAttribute(Name="TimeApp")]
	public partial class TimeAppDataContext : System.Data.Linq.DataContext
	{
		
		private static System.Data.Linq.Mapping.MappingSource mappingSource = new AttributeMappingSource();
		
    #region Extensibility Method Definitions
    partial void OnCreated();
    partial void InsertActivityType(ActivityType instance);
    partial void UpdateActivityType(ActivityType instance);
    partial void DeleteActivityType(ActivityType instance);
    partial void InsertLogEntry(LogEntry instance);
    partial void UpdateLogEntry(LogEntry instance);
    partial void DeleteLogEntry(LogEntry instance);
    partial void InsertProject(Project instance);
    partial void UpdateProject(Project instance);
    partial void DeleteProject(Project instance);
    partial void InsertTask(Task instance);
    partial void UpdateTask(Task instance);
    partial void DeleteTask(Task instance);
    #endregion
		
		public TimeAppDataContext(string connection) : 
				base(connection, mappingSource)
		{
			OnCreated();
		}
		
		public TimeAppDataContext(System.Data.IDbConnection connection) : 
				base(connection, mappingSource)
		{
			OnCreated();
		}
		
		public TimeAppDataContext(string connection, System.Data.Linq.Mapping.MappingSource mappingSource) : 
				base(connection, mappingSource)
		{
			OnCreated();
		}
		
		public TimeAppDataContext(System.Data.IDbConnection connection, System.Data.Linq.Mapping.MappingSource mappingSource) : 
				base(connection, mappingSource)
		{
			OnCreated();
		}
		
		public System.Data.Linq.Table<ActivityType> ActivityTypes
		{
			get
			{
				return this.GetTable<ActivityType>();
			}
		}
		
		public System.Data.Linq.Table<LogEntry> LogEntries
		{
			get
			{
				return this.GetTable<LogEntry>();
			}
		}
		
		public System.Data.Linq.Table<Project> Projects
		{
			get
			{
				return this.GetTable<Project>();
			}
		}
		
		public System.Data.Linq.Table<Task> Tasks
		{
			get
			{
				return this.GetTable<Task>();
			}
		}
	}
	
	[Table()]
	public partial class ActivityType : INotifyPropertyChanging, INotifyPropertyChanged
	{
		
		private static PropertyChangingEventArgs emptyChangingEventArgs = new PropertyChangingEventArgs(String.Empty);
		
		private int _ActivityTypeId;
		
		private string _Name;
		
		private EntitySet<LogEntry> _LogEntries;
		
    #region Extensibility Method Definitions
    partial void OnLoaded();
    partial void OnValidate(System.Data.Linq.ChangeAction action);
    partial void OnCreated();
    partial void OnActivityTypeIdChanging(int value);
    partial void OnActivityTypeIdChanged();
    partial void OnNameChanging(string value);
    partial void OnNameChanged();
    #endregion
		
		public ActivityType()
		{
			this._LogEntries = new EntitySet<LogEntry>(new Action<LogEntry>(this.attach_LogEntries), new Action<LogEntry>(this.detach_LogEntries));
			OnCreated();
		}
		
		[Column(Storage="_ActivityTypeId", AutoSync=AutoSync.OnInsert, DbType="Int NOT NULL IDENTITY", IsPrimaryKey=true, IsDbGenerated=true)]
		public int ActivityTypeId
		{
			get
			{
				return this._ActivityTypeId;
			}
			set
			{
				if ((this._ActivityTypeId != value))
				{
					this.OnActivityTypeIdChanging(value);
					this.SendPropertyChanging();
					this._ActivityTypeId = value;
					this.SendPropertyChanged("ActivityTypeId");
					this.OnActivityTypeIdChanged();
				}
			}
		}
		
		[Column(Storage="_Name", DbType="NVarChar(50) NOT NULL", CanBeNull=false)]
		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="ActivityType_LogEntry", Storage="_LogEntries", OtherKey="ActivityTypeId")]
		public EntitySet<LogEntry> LogEntries
		{
			get
			{
				return this._LogEntries;
			}
			set
			{
				this._LogEntries.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_LogEntries(LogEntry entity)
		{
			this.SendPropertyChanging();
			entity.ActivityType = this;
		}
		
		private void detach_LogEntries(LogEntry entity)
		{
			this.SendPropertyChanging();
			entity.ActivityType = null;
		}
	}
	
	[Table()]
	public partial class LogEntry : INotifyPropertyChanging, INotifyPropertyChanged
	{
		
		private static PropertyChangingEventArgs emptyChangingEventArgs = new PropertyChangingEventArgs(String.Empty);
		
		private int _LogEntryId;
		
		private System.Nullable<System.DateTime> _BeginTime;
		
		private System.Nullable<System.DateTime> _EndTime;
		
		private int _ProjectId;
		
		private System.Nullable<int> _TaskId;
		
		private System.Nullable<int> _ActivityTypeId;
		
		private bool _IsBillable;
		
		private string _Description;
		
		private int _Duration;
		
		private EntityRef<ActivityType> _ActivityType;
		
		private EntityRef<Project> _Project;
		
		private EntityRef<Task> _Task;
		
    #region Extensibility Method Definitions
    partial void OnLoaded();
    partial void OnValidate(System.Data.Linq.ChangeAction action);
    partial void OnCreated();
    partial void OnLogEntryIdChanging(int value);
    partial void OnLogEntryIdChanged();
    partial void OnBeginTimeChanging(System.Nullable<System.DateTime> value);
    partial void OnBeginTimeChanged();
    partial void OnEndTimeChanging(System.Nullable<System.DateTime> value);
    partial void OnEndTimeChanged();
    partial void OnProjectIdChanging(int value);
    partial void OnProjectIdChanged();
    partial void OnTaskIdChanging(System.Nullable<int> value);
    partial void OnTaskIdChanged();
    partial void OnActivityTypeIdChanging(System.Nullable<int> value);
    partial void OnActivityTypeIdChanged();
    partial void OnIsBillableChanging(bool value);
    partial void OnIsBillableChanged();
    partial void OnDescriptionChanging(string value);
    partial void OnDescriptionChanged();
    partial void OnDurationChanging(int value);
    partial void OnDurationChanged();
    #endregion
		
		public LogEntry()
		{
			this._ActivityType = default(EntityRef<ActivityType>);
			this._Project = default(EntityRef<Project>);
			this._Task = default(EntityRef<Task>);
			OnCreated();
		}
		
		[Column(Storage="_LogEntryId", AutoSync=AutoSync.OnInsert, DbType="Int NOT NULL IDENTITY", IsPrimaryKey=true, IsDbGenerated=true)]
		public int LogEntryId
		{
			get
			{
				return this._LogEntryId;
			}
			set
			{
				if ((this._LogEntryId != value))
				{
					this.OnLogEntryIdChanging(value);
					this.SendPropertyChanging();
					this._LogEntryId = value;
					this.SendPropertyChanged("LogEntryId");
					this.OnLogEntryIdChanged();
				}
			}
		}
		
		[Column(Storage="_BeginTime", DbType="DateTime")]
		public System.Nullable<System.DateTime> BeginTime
		{
			get
			{
				return this._BeginTime;
			}
			set
			{
				if ((this._BeginTime != value))
				{
					this.OnBeginTimeChanging(value);
					this.SendPropertyChanging();
					this._BeginTime = value;
					this.SendPropertyChanged("BeginTime");
					this.OnBeginTimeChanged();
				}
			}
		}
		
		[Column(Storage="_EndTime", DbType="DateTime")]
		public System.Nullable<System.DateTime> EndTime
		{
			get
			{
				return this._EndTime;
			}
			set
			{
				if ((this._EndTime != value))
				{
					this.OnEndTimeChanging(value);
					this.SendPropertyChanging();
					this._EndTime = value;
					this.SendPropertyChanged("EndTime");
					this.OnEndTimeChanged();
				}
			}
		}
		
		[Column(Storage="_ProjectId", DbType="Int NOT NULL")]
		public int ProjectId
		{
			get
			{
				return this._ProjectId;
			}
			set
			{
				if ((this._ProjectId != value))
				{
					if (this._Project.HasLoadedOrAssignedValue)
					{
						throw new System.Data.Linq.ForeignKeyReferenceAlreadyHasValueException();
					}
					this.OnProjectIdChanging(value);
					this.SendPropertyChanging();
					this._ProjectId = value;
					this.SendPropertyChanged("ProjectId");
					this.OnProjectIdChanged();
				}
			}
		}
		
		[Column(Storage="_TaskId", DbType="Int")]
		public System.Nullable<int> TaskId
		{
			get
			{
				return this._TaskId;
			}
			set
			{
				if ((this._TaskId != value))
				{
					if (this._Task.HasLoadedOrAssignedValue)
					{
						throw new System.Data.Linq.ForeignKeyReferenceAlreadyHasValueException();
					}
					this.OnTaskIdChanging(value);
					this.SendPropertyChanging();
					this._TaskId = value;
					this.SendPropertyChanged("TaskId");
					this.OnTaskIdChanged();
				}
			}
		}
		
		[Column(Storage="_ActivityTypeId", DbType="Int")]
		public System.Nullable<int> ActivityTypeId
		{
			get
			{
				return this._ActivityTypeId;
			}
			set
			{
				if ((this._ActivityTypeId != value))
				{
					if (this._ActivityType.HasLoadedOrAssignedValue)
					{
						throw new System.Data.Linq.ForeignKeyReferenceAlreadyHasValueException();
					}
					this.OnActivityTypeIdChanging(value);
					this.SendPropertyChanging();
					this._ActivityTypeId = value;
					this.SendPropertyChanged("ActivityTypeId");
					this.OnActivityTypeIdChanged();
				}
			}
		}
		
		[Column(Storage="_IsBillable", DbType="Bit NOT NULL")]
		public bool IsBillable
		{
			get
			{
				return this._IsBillable;
			}
			set
			{
				if ((this._IsBillable != value))
				{
					this.OnIsBillableChanging(value);
					this.SendPropertyChanging();
					this._IsBillable = value;
					this.SendPropertyChanged("IsBillable");
					this.OnIsBillableChanged();
				}
			}
		}
		
		[Column(Storage="_Description", DbType="NVarChar(750)")]
		public string Description
		{
			get
			{
				return this._Description;
			}
			set
			{
				if ((this._Description != value))
				{
					this.OnDescriptionChanging(value);
					this.SendPropertyChanging();
					this._Description = value;
					this.SendPropertyChanged("Description");
					this.OnDescriptionChanged();
				}
			}
		}
		
		[Column(Storage="_Duration", DbType="Int NOT NULL")]
		public int Duration
		{
			get
			{
				return this._Duration;
			}
			set
			{
				if ((this._Duration != value))
				{
					this.OnDurationChanging(value);
					this.SendPropertyChanging();
					this._Duration = value;
					this.SendPropertyChanged("Duration");
					this.OnDurationChanged();
				}
			}
		}
		
		[Association(Name="ActivityType_LogEntry", Storage="_ActivityType", ThisKey="ActivityTypeId", IsForeignKey=true)]
		public ActivityType ActivityType
		{
			get
			{
				return this._ActivityType.Entity;
			}
			set
			{
				ActivityType previousValue = this._ActivityType.Entity;
				if (((previousValue != value) 
							|| (this._ActivityType.HasLoadedOrAssignedValue == false)))
				{
					this.SendPropertyChanging();
					if ((previousValue != null))
					{
						this._ActivityType.Entity = null;
						previousValue.LogEntries.Remove(this);
					}
					this._ActivityType.Entity = value;
					if ((value != null))
					{
						value.LogEntries.Add(this);
						this._ActivityTypeId = value.ActivityTypeId;
					}
					else
					{
						this._ActivityTypeId = default(Nullable<int>);
					}
					this.SendPropertyChanged("ActivityType");
				}
			}
		}
		
		[Association(Name="Project_LogEntry", Storage="_Project", ThisKey="ProjectId", IsForeignKey=true)]
		public Project Project
		{
			get
			{
				return this._Project.Entity;
			}
			set
			{
				Project previousValue = this._Project.Entity;
				if (((previousValue != value) 
							|| (this._Project.HasLoadedOrAssignedValue == false)))
				{
					this.SendPropertyChanging();
					if ((previousValue != null))
					{
						this._Project.Entity = null;
						previousValue.LogEntries.Remove(this);
					}
					this._Project.Entity = value;
					if ((value != null))
					{
						value.LogEntries.Add(this);
						this._ProjectId = value.ProjectId;
					}
					else
					{
						this._ProjectId = default(int);
					}
					this.SendPropertyChanged("Project");
				}
			}
		}
		
		[Association(Name="Task_LogEntry", Storage="_Task", ThisKey="TaskId", IsForeignKey=true)]
		public Task Task
		{
			get
			{
				return this._Task.Entity;
			}
			set
			{
				Task previousValue = this._Task.Entity;
				if (((previousValue != value) 
							|| (this._Task.HasLoadedOrAssignedValue == false)))
				{
					this.SendPropertyChanging();
					if ((previousValue != null))
					{
						this._Task.Entity = null;
						previousValue.LogEntries.Remove(this);
					}
					this._Task.Entity = value;
					if ((value != null))
					{
						value.LogEntries.Add(this);
						this._TaskId = value.TaskId;
					}
					else
					{
						this._TaskId = default(Nullable<int>);
					}
					this.SendPropertyChanged("Task");
				}
			}
		}
		
		public event PropertyChangingEventHandler PropertyChanging;
		
		public event PropertyChangedEventHandler PropertyChanged;
		
		protected virtual void SendPropertyChanging()
		{
			if ((this.PropertyChanging != null))
			{
				this.PropertyChanging(this, emptyChangingEventArgs);
			}
		}
		
		protected virtual void SendPropertyChanged(String propertyName)
		{
			if ((this.PropertyChanged != null))
			{
				this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
			}
		}
	}
	
	[Table()]
	public partial class Project : INotifyPropertyChanging, INotifyPropertyChanged
	{
		
		private static PropertyChangingEventArgs emptyChangingEventArgs = new PropertyChangingEventArgs(String.Empty);
		
		private int _ProjectId;
		
		private string _Name;
		
		private bool _IsBillable;
		
		private bool _DetectAway;
		
		private bool _IsComplete;
		
		private string _Code;
		
		private System.Nullable<int> _EstimatedDuration;
		
		private System.Nullable<EstimationComparisonType> _EstimationComparisonType;
		
		private EntitySet<LogEntry> _LogEntries;
		
		private EntitySet<Task> _Tasks;
		
    #region Extensibility Method Definitions
    partial void OnLoaded();
    partial void OnValidate(System.Data.Linq.ChangeAction action);
    partial void OnCreated();
    partial void OnProjectIdChanging(int value);
    partial void OnProjectIdChanged();
    partial void OnNameChanging(string value);
    partial void OnNameChanged();
    partial void OnIsBillableChanging(bool value);
    partial void OnIsBillableChanged();
    partial void OnDetectAwayChanging(bool value);
    partial void OnDetectAwayChanged();
    partial void OnIsCompleteChanging(bool value);
    partial void OnIsCompleteChanged();
    partial void OnCodeChanging(string value);
    partial void OnCodeChanged();
    partial void OnEstimatedDurationChanging(System.Nullable<int> value);
    partial void OnEstimatedDurationChanged();
    partial void OnEstimationComparisonTypeChanging(System.Nullable<EstimationComparisonType> value);
    partial void OnEstimationComparisonTypeChanged();
    #endregion
		
		public Project()
		{
			this._LogEntries = new EntitySet<LogEntry>(new Action<LogEntry>(this.attach_LogEntries), new Action<LogEntry>(this.detach_LogEntries));
			this._Tasks = new EntitySet<Task>(new Action<Task>(this.attach_Tasks), new Action<Task>(this.detach_Tasks));
			OnCreated();
		}
		
		[Column(Storage="_ProjectId", AutoSync=AutoSync.OnInsert, DbType="Int NOT NULL IDENTITY", IsPrimaryKey=true, IsDbGenerated=true)]
		public int ProjectId
		{
			get
			{
				return this._ProjectId;
			}
			set
			{
				if ((this._ProjectId != value))
				{
					this.OnProjectIdChanging(value);
					this.SendPropertyChanging();
					this._ProjectId = value;
					this.SendPropertyChanged("ProjectId");
					this.OnProjectIdChanged();
				}
			}
		}
		
		[Column(Storage="_Name", DbType="NVarChar(100) NOT NULL", CanBeNull=false)]
		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="_IsBillable", DbType="Bit NOT NULL")]
		public bool IsBillable
		{
			get
			{
				return this._IsBillable;
			}
			set
			{
				if ((this._IsBillable != value))
				{
					this.OnIsBillableChanging(value);
					this.SendPropertyChanging();
					this._IsBillable = value;
					this.SendPropertyChanged("IsBillable");
					this.OnIsBillableChanged();
				}
			}
		}
		
		[Column(Storage="_DetectAway", DbType="Bit NOT NULL")]
		public bool DetectAway
		{
			get
			{
				return this._DetectAway;
			}
			set
			{
				if ((this._DetectAway != value))
				{
					this.OnDetectAwayChanging(value);
					this.SendPropertyChanging();
					this._DetectAway = value;
					this.SendPropertyChanged("DetectAway");
					this.OnDetectAwayChanged();
				}
			}
		}
		
		[Column(Storage="_IsComplete", DbType="Bit NOT NULL")]
		public bool IsComplete
		{
			get
			{
				return this._IsComplete;
			}
			set
			{
				if ((this._IsComplete != value))
				{
					this.OnIsCompleteChanging(value);
					this.SendPropertyChanging();
					this._IsComplete = value;
					this.SendPropertyChanged("IsComplete");
					this.OnIsCompleteChanged();
				}
			}
		}
		
		[Column(Storage="_Code", DbType="NVarChar(25)")]
		public string Code
		{
			get
			{
				return this._Code;
			}
			set
			{
				if ((this._Code != value))
				{
					this.OnCodeChanging(value);
					this.SendPropertyChanging();
					this._Code = value;
					this.SendPropertyChanged("Code");
					this.OnCodeChanged();
				}
			}
		}
		
		[Column(Storage="_EstimatedDuration", DbType="Int")]
		public System.Nullable<int> EstimatedDuration
		{
			get
			{
				return this._EstimatedDuration;
			}
			set
			{
				if ((this._EstimatedDuration != value))
				{
					this.OnEstimatedDurationChanging(value);
					this.SendPropertyChanging();
					this._EstimatedDuration = value;
					this.SendPropertyChanged("EstimatedDuration");
					this.OnEstimatedDurationChanged();
				}
			}
		}
		
		[Column(Storage="_EstimationComparisonType", DbType="TinyInt", CanBeNull=true)]
		public System.Nullable<EstimationComparisonType> EstimationComparisonType
		{
			get
			{
				return this._EstimationComparisonType;
			}
			set
			{
				if ((this._EstimationComparisonType != value))
				{
					this.OnEstimationComparisonTypeChanging(value);
					this.SendPropertyChanging();
					this._EstimationComparisonType = value;
					this.SendPropertyChanged("EstimationComparisonType");
					this.OnEstimationComparisonTypeChanged();
				}
			}
		}
		
		[Association(Name="Project_LogEntry", Storage="_LogEntries", OtherKey="ProjectId")]
		public EntitySet<LogEntry> LogEntries
		{
			get
			{
				return this._LogEntries;
			}
			set
			{
				this._LogEntries.Assign(value);
			}
		}
		
		[Association(Name="Project_Task", Storage="_Tasks", OtherKey="ProjectId")]
		public EntitySet<Task> Tasks
		{
			get
			{
				return this._Tasks;
			}
			set
			{
				this._Tasks.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_LogEntries(LogEntry entity)
		{
			this.SendPropertyChanging();
			entity.Project = this;
		}
		
		private void detach_LogEntries(LogEntry entity)
		{
			this.SendPropertyChanging();
			entity.Project = null;
		}
		
		private void attach_Tasks(Task entity)
		{
			this.SendPropertyChanging();
			entity.Project = this;
		}
		
		private void detach_Tasks(Task entity)
		{
			this.SendPropertyChanging();
			entity.Project = null;
		}
	}
	
	[Table()]
	public partial class Task : INotifyPropertyChanging, INotifyPropertyChanged
	{
		
		private static PropertyChangingEventArgs emptyChangingEventArgs = new PropertyChangingEventArgs(String.Empty);
		
		private int _TaskId;
		
		private int _ProjectId;
		
		private string _Name;
		
		private bool _IsBillable;
		
		private bool _DetectAway;
		
		private bool _IsComplete;
		
		private string _Code;
		
		private System.Nullable<int> _EstimatedDuration;
		
		private System.Nullable<EstimationComparisonType> _EstimationComparisonType;
		
		private EntitySet<LogEntry> _LogEntries;
		
		private EntityRef<Project> _Project;
		
    #region Extensibility Method Definitions
    partial void OnLoaded();
    partial void OnValidate(System.Data.Linq.ChangeAction action);
    partial void OnCreated();
    partial void OnTaskIdChanging(int value);
    partial void OnTaskIdChanged();
    partial void OnProjectIdChanging(int value);
    partial void OnProjectIdChanged();
    partial void OnNameChanging(string value);
    partial void OnNameChanged();
    partial void OnIsBillableChanging(bool value);
    partial void OnIsBillableChanged();
    partial void OnDetectAwayChanging(bool value);
    partial void OnDetectAwayChanged();
    partial void OnIsCompleteChanging(bool value);
    partial void OnIsCompleteChanged();
    partial void OnCodeChanging(string value);
    partial void OnCodeChanged();
    partial void OnEstimatedDurationChanging(System.Nullable<int> value);
    partial void OnEstimatedDurationChanged();
    partial void OnEstimationComparisonTypeChanging(System.Nullable<EstimationComparisonType> value);
    partial void OnEstimationComparisonTypeChanged();
    #endregion
		
		public Task()
		{
			this._LogEntries = new EntitySet<LogEntry>(new Action<LogEntry>(this.attach_LogEntries), new Action<LogEntry>(this.detach_LogEntries));
			this._Project = default(EntityRef<Project>);
			OnCreated();
		}
		
		[Column(Storage="_TaskId", AutoSync=AutoSync.OnInsert, DbType="Int NOT NULL IDENTITY", IsPrimaryKey=true, IsDbGenerated=true)]
		public int TaskId
		{
			get
			{
				return this._TaskId;
			}
			set
			{
				if ((this._TaskId != value))
				{
					this.OnTaskIdChanging(value);
					this.SendPropertyChanging();
					this._TaskId = value;
					this.SendPropertyChanged("TaskId");
					this.OnTaskIdChanged();
				}
			}
		}
		
		[Column(Storage="_ProjectId", DbType="Int NOT NULL")]
		public int ProjectId
		{
			get
			{
				return this._ProjectId;
			}
			set
			{
				if ((this._ProjectId != value))
				{
					if (this._Project.HasLoadedOrAssignedValue)
					{
						throw new System.Data.Linq.ForeignKeyReferenceAlreadyHasValueException();
					}
					this.OnProjectIdChanging(value);
					this.SendPropertyChanging();
					this._ProjectId = value;
					this.SendPropertyChanged("ProjectId");
					this.OnProjectIdChanged();
				}
			}
		}
		
		[Column(Storage="_Name", DbType="NVarChar(100) NOT NULL", CanBeNull=false)]
		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="_IsBillable", DbType="Bit NOT NULL")]
		public bool IsBillable
		{
			get
			{
				return this._IsBillable;
			}
			set
			{
				if ((this._IsBillable != value))
				{
					this.OnIsBillableChanging(value);
					this.SendPropertyChanging();
					this._IsBillable = value;
					this.SendPropertyChanged("IsBillable");
					this.OnIsBillableChanged();
				}
			}
		}
		
		[Column(Storage="_DetectAway", DbType="Bit NOT NULL")]
		public bool DetectAway
		{
			get
			{
				return this._DetectAway;
			}
			set
			{
				if ((this._DetectAway != value))
				{
					this.OnDetectAwayChanging(value);
					this.SendPropertyChanging();
					this._DetectAway = value;
					this.SendPropertyChanged("DetectAway");
					this.OnDetectAwayChanged();
				}
			}
		}
		
		[Column(Storage="_IsComplete", DbType="Bit NOT NULL")]
		public bool IsComplete
		{
			get
			{
				return this._IsComplete;
			}
			set
			{
				if ((this._IsComplete != value))
				{
					this.OnIsCompleteChanging(value);
					this.SendPropertyChanging();
					this._IsComplete = value;
					this.SendPropertyChanged("IsComplete");
					this.OnIsCompleteChanged();
				}
			}
		}
		
		[Column(Storage="_Code", DbType="NVarChar(25)")]
		public string Code
		{
			get
			{
				return this._Code;
			}
			set
			{
				if ((this._Code != value))
				{
					this.OnCodeChanging(value);
					this.SendPropertyChanging();
					this._Code = value;
					this.SendPropertyChanged("Code");
					this.OnCodeChanged();
				}
			}
		}
		
		[Column(Storage="_EstimatedDuration", DbType="Int")]
		public System.Nullable<int> EstimatedDuration
		{
			get
			{
				return this._EstimatedDuration;
			}
			set
			{
				if ((this._EstimatedDuration != value))
				{
					this.OnEstimatedDurationChanging(value);
					this.SendPropertyChanging();
					this._EstimatedDuration = value;
					this.SendPropertyChanged("EstimatedDuration");
					this.OnEstimatedDurationChanged();
				}
			}
		}
		
		[Column(Storage="_EstimationComparisonType", DbType="TinyInt", CanBeNull=true)]
		public System.Nullable<EstimationComparisonType> EstimationComparisonType
		{
			get
			{
				return this._EstimationComparisonType;
			}
			set
			{
				if ((this._EstimationComparisonType != value))
				{
					this.OnEstimationComparisonTypeChanging(value);
					this.SendPropertyChanging();
					this._EstimationComparisonType = value;
					this.SendPropertyChanged("EstimationComparisonType");
					this.OnEstimationComparisonTypeChanged();
				}
			}
		}
		
		[Association(Name="Task_LogEntry", Storage="_LogEntries", OtherKey="TaskId")]
		public EntitySet<LogEntry> LogEntries
		{
			get
			{
				return this._LogEntries;
			}
			set
			{
				this._LogEntries.Assign(value);
			}
		}
		
		[Association(Name="Project_Task", Storage="_Project", ThisKey="ProjectId", IsForeignKey=true)]
		public Project Project
		{
			get
			{
				return this._Project.Entity;
			}
			set
			{
				Project previousValue = this._Project.Entity;
				if (((previousValue != value) 
							|| (this._Project.HasLoadedOrAssignedValue == false)))
				{
					this.SendPropertyChanging();
					if ((previousValue != null))
					{
						this._Project.Entity = null;
						previousValue.Tasks.Remove(this);
					}
					this._Project.Entity = value;
					if ((value != null))
					{
						value.Tasks.Add(this);
						this._ProjectId = value.ProjectId;
					}
					else
					{
						this._ProjectId = default(int);
					}
					this.SendPropertyChanged("Project");
				}
			}
		}
		
		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_LogEntries(LogEntry entity)
		{
			this.SendPropertyChanging();
			entity.Task = this;
		}
		
		private void detach_LogEntries(LogEntry entity)
		{
			this.SendPropertyChanging();
			entity.Task = null;
		}
	}
}
#pragma warning restore 1591

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

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

License

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

Share

About the Author

Matt Sollars
Web Developer
United States United States
I began programming on my Commodore 64 at around the age of 12. After migrating to DOS and then Windows, I decided to take on the Web. Several languages and platforms later, I have settled in with .NET nicely. I am currently the owner of a software consulting company and lead application developer for a learning-based technology consultation company.
 
The love of a finished application is usually at war with the desire to improve it as soon as it's released (they're never really finished).

| Advertise | Privacy | Mobile
Web01 | 2.8.140905.1 | Last Updated 25 Mar 2008
Article Copyright 2007 by Matt Sollars
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid