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

Preventive Method for URL Request Forgery- An Example with ASP.NET MVC

Rate me:
Please Sign up or sign in to vote.
4.75/5 (13 votes)
29 Nov 2010CPOL7 min read 76K   1.7K   33  
It is novel method to prevent the manipulation of parameter pass through the URL string
#pragma warning disable 1591
//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a tool.
//     Runtime Version:4.0.30319.1
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

namespace SecureUrl
{
	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;
	
	
	[global::System.Data.Linq.Mapping.DatabaseAttribute(Name="Students")]
	public partial class SecureUrlDataContext : System.Data.Linq.DataContext
	{
		
		private static System.Data.Linq.Mapping.MappingSource mappingSource = new AttributeMappingSource();
		
    #region Extensibility Method Definitions
    partial void OnCreated();
    partial void InsertSubject(Subject instance);
    partial void UpdateSubject(Subject instance);
    partial void DeleteSubject(Subject instance);
    partial void InsertExam(Exam instance);
    partial void UpdateExam(Exam instance);
    partial void DeleteExam(Exam instance);
    partial void InsertStudentSubject(StudentSubject instance);
    partial void UpdateStudentSubject(StudentSubject instance);
    partial void DeleteStudentSubject(StudentSubject instance);
    partial void InsertStudent(Student instance);
    partial void UpdateStudent(Student instance);
    partial void DeleteStudent(Student instance);
    partial void InsertQuestion(Question instance);
    partial void UpdateQuestion(Question instance);
    partial void DeleteQuestion(Question instance);
    #endregion
		
		public SecureUrlDataContext() : 
				base(global::System.Configuration.ConfigurationManager.ConnectionStrings["StudentsConnectionString"].ConnectionString, mappingSource)
		{
			OnCreated();
		}
		
		public SecureUrlDataContext(string connection) : 
				base(connection, mappingSource)
		{
			OnCreated();
		}
		
		public SecureUrlDataContext(System.Data.IDbConnection connection) : 
				base(connection, mappingSource)
		{
			OnCreated();
		}
		
		public SecureUrlDataContext(string connection, System.Data.Linq.Mapping.MappingSource mappingSource) : 
				base(connection, mappingSource)
		{
			OnCreated();
		}
		
		public SecureUrlDataContext(System.Data.IDbConnection connection, System.Data.Linq.Mapping.MappingSource mappingSource) : 
				base(connection, mappingSource)
		{
			OnCreated();
		}
		
		public System.Data.Linq.Table<Subject> Subjects
		{
			get
			{
				return this.GetTable<Subject>();
			}
		}
		
		public System.Data.Linq.Table<Exam> Exams
		{
			get
			{
				return this.GetTable<Exam>();
			}
		}
		
		public System.Data.Linq.Table<StudentSubject> StudentSubjects
		{
			get
			{
				return this.GetTable<StudentSubject>();
			}
		}
		
		public System.Data.Linq.Table<Student> Students
		{
			get
			{
				return this.GetTable<Student>();
			}
		}
		
		public System.Data.Linq.Table<Question> Questions
		{
			get
			{
				return this.GetTable<Question>();
			}
		}
	}
	
	[global::System.Data.Linq.Mapping.TableAttribute(Name="dbo.Subjects")]
	public partial class Subject : INotifyPropertyChanging, INotifyPropertyChanged
	{
		
		private static PropertyChangingEventArgs emptyChangingEventArgs = new PropertyChangingEventArgs(String.Empty);
		
		private int _SubjectId;
		
		private string _Name;
		
		private EntitySet<Exam> _Exams;
		
		private EntitySet<StudentSubject> _StudentSubjects;
		
    #region Extensibility Method Definitions
    partial void OnLoaded();
    partial void OnValidate(System.Data.Linq.ChangeAction action);
    partial void OnCreated();
    partial void OnSubjectIdChanging(int value);
    partial void OnSubjectIdChanged();
    partial void OnNameChanging(string value);
    partial void OnNameChanged();
    #endregion
		
		public Subject()
		{
			this._Exams = new EntitySet<Exam>(new Action<Exam>(this.attach_Exams), new Action<Exam>(this.detach_Exams));
			this._StudentSubjects = new EntitySet<StudentSubject>(new Action<StudentSubject>(this.attach_StudentSubjects), new Action<StudentSubject>(this.detach_StudentSubjects));
			OnCreated();
		}
		
		[global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_SubjectId", AutoSync=AutoSync.OnInsert, DbType="Int NOT NULL IDENTITY", IsPrimaryKey=true, IsDbGenerated=true)]
		public int SubjectId
		{
			get
			{
				return this._SubjectId;
			}
			set
			{
				if ((this._SubjectId != value))
				{
					this.OnSubjectIdChanging(value);
					this.SendPropertyChanging();
					this._SubjectId = value;
					this.SendPropertyChanged("SubjectId");
					this.OnSubjectIdChanged();
				}
			}
		}
		
		[global::System.Data.Linq.Mapping.ColumnAttribute(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();
				}
			}
		}
		
		[global::System.Data.Linq.Mapping.AssociationAttribute(Name="Subject_Exam", Storage="_Exams", ThisKey="SubjectId", OtherKey="SubjectId")]
		public EntitySet<Exam> Exams
		{
			get
			{
				return this._Exams;
			}
			set
			{
				this._Exams.Assign(value);
			}
		}
		
		[global::System.Data.Linq.Mapping.AssociationAttribute(Name="Subject_StudentSubject", Storage="_StudentSubjects", ThisKey="SubjectId", OtherKey="SubjectId")]
		public EntitySet<StudentSubject> StudentSubjects
		{
			get
			{
				return this._StudentSubjects;
			}
			set
			{
				this._StudentSubjects.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_Exams(Exam entity)
		{
			this.SendPropertyChanging();
			entity.Subject = this;
		}
		
		private void detach_Exams(Exam entity)
		{
			this.SendPropertyChanging();
			entity.Subject = null;
		}
		
		private void attach_StudentSubjects(StudentSubject entity)
		{
			this.SendPropertyChanging();
			entity.Subject = this;
		}
		
		private void detach_StudentSubjects(StudentSubject entity)
		{
			this.SendPropertyChanging();
			entity.Subject = null;
		}
	}
	
	[global::System.Data.Linq.Mapping.TableAttribute(Name="dbo.Exams")]
	public partial class Exam : INotifyPropertyChanging, INotifyPropertyChanged
	{
		
		private static PropertyChangingEventArgs emptyChangingEventArgs = new PropertyChangingEventArgs(String.Empty);
		
		private int _ExamId;
		
		private string _Name;
		
		private System.DateTime _CommenceDate;
		
		private int _SubjectId;
		
		private EntitySet<Question> _Questions;
		
		private EntityRef<Subject> _Subject;
		
    #region Extensibility Method Definitions
    partial void OnLoaded();
    partial void OnValidate(System.Data.Linq.ChangeAction action);
    partial void OnCreated();
    partial void OnExamIdChanging(int value);
    partial void OnExamIdChanged();
    partial void OnNameChanging(string value);
    partial void OnNameChanged();
    partial void OnCommenceDateChanging(System.DateTime value);
    partial void OnCommenceDateChanged();
    partial void OnSubjectIdChanging(int value);
    partial void OnSubjectIdChanged();
    #endregion
		
		public Exam()
		{
			this._Questions = new EntitySet<Question>(new Action<Question>(this.attach_Questions), new Action<Question>(this.detach_Questions));
			this._Subject = default(EntityRef<Subject>);
			OnCreated();
		}
		
		[global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_ExamId", AutoSync=AutoSync.OnInsert, DbType="Int NOT NULL IDENTITY", IsPrimaryKey=true, IsDbGenerated=true)]
		public int ExamId
		{
			get
			{
				return this._ExamId;
			}
			set
			{
				if ((this._ExamId != value))
				{
					this.OnExamIdChanging(value);
					this.SendPropertyChanging();
					this._ExamId = value;
					this.SendPropertyChanged("ExamId");
					this.OnExamIdChanged();
				}
			}
		}
		
		[global::System.Data.Linq.Mapping.ColumnAttribute(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();
				}
			}
		}
		
		[global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_CommenceDate", DbType="DateTime NOT NULL")]
		public System.DateTime CommenceDate
		{
			get
			{
				return this._CommenceDate;
			}
			set
			{
				if ((this._CommenceDate != value))
				{
					this.OnCommenceDateChanging(value);
					this.SendPropertyChanging();
					this._CommenceDate = value;
					this.SendPropertyChanged("CommenceDate");
					this.OnCommenceDateChanged();
				}
			}
		}
		
		[global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_SubjectId", DbType="Int NOT NULL")]
		public int SubjectId
		{
			get
			{
				return this._SubjectId;
			}
			set
			{
				if ((this._SubjectId != value))
				{
					if (this._Subject.HasLoadedOrAssignedValue)
					{
						throw new System.Data.Linq.ForeignKeyReferenceAlreadyHasValueException();
					}
					this.OnSubjectIdChanging(value);
					this.SendPropertyChanging();
					this._SubjectId = value;
					this.SendPropertyChanged("SubjectId");
					this.OnSubjectIdChanged();
				}
			}
		}
		
		[global::System.Data.Linq.Mapping.AssociationAttribute(Name="Exam_Question", Storage="_Questions", ThisKey="ExamId", OtherKey="ExamId")]
		public EntitySet<Question> Questions
		{
			get
			{
				return this._Questions;
			}
			set
			{
				this._Questions.Assign(value);
			}
		}
		
		[global::System.Data.Linq.Mapping.AssociationAttribute(Name="Subject_Exam", Storage="_Subject", ThisKey="SubjectId", OtherKey="SubjectId", IsForeignKey=true)]
		public Subject Subject
		{
			get
			{
				return this._Subject.Entity;
			}
			set
			{
				Subject previousValue = this._Subject.Entity;
				if (((previousValue != value) 
							|| (this._Subject.HasLoadedOrAssignedValue == false)))
				{
					this.SendPropertyChanging();
					if ((previousValue != null))
					{
						this._Subject.Entity = null;
						previousValue.Exams.Remove(this);
					}
					this._Subject.Entity = value;
					if ((value != null))
					{
						value.Exams.Add(this);
						this._SubjectId = value.SubjectId;
					}
					else
					{
						this._SubjectId = default(int);
					}
					this.SendPropertyChanged("Subject");
				}
			}
		}
		
		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_Questions(Question entity)
		{
			this.SendPropertyChanging();
			entity.Exam = this;
		}
		
		private void detach_Questions(Question entity)
		{
			this.SendPropertyChanging();
			entity.Exam = null;
		}
	}
	
	[global::System.Data.Linq.Mapping.TableAttribute(Name="dbo.StudentSubjects")]
	public partial class StudentSubject : INotifyPropertyChanging, INotifyPropertyChanged
	{
		
		private static PropertyChangingEventArgs emptyChangingEventArgs = new PropertyChangingEventArgs(String.Empty);
		
		private int _SubjectAssignmentId;
		
		private int _SubjectId;
		
		private string _UserId;
		
		private EntityRef<Subject> _Subject;
		
		private EntityRef<Student> _Student;
		
    #region Extensibility Method Definitions
    partial void OnLoaded();
    partial void OnValidate(System.Data.Linq.ChangeAction action);
    partial void OnCreated();
    partial void OnSubjectAssignmentIdChanging(int value);
    partial void OnSubjectAssignmentIdChanged();
    partial void OnSubjectIdChanging(int value);
    partial void OnSubjectIdChanged();
    partial void OnUserIdChanging(string value);
    partial void OnUserIdChanged();
    #endregion
		
		public StudentSubject()
		{
			this._Subject = default(EntityRef<Subject>);
			this._Student = default(EntityRef<Student>);
			OnCreated();
		}
		
		[global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_SubjectAssignmentId", AutoSync=AutoSync.OnInsert, DbType="Int NOT NULL IDENTITY", IsPrimaryKey=true, IsDbGenerated=true)]
		public int SubjectAssignmentId
		{
			get
			{
				return this._SubjectAssignmentId;
			}
			set
			{
				if ((this._SubjectAssignmentId != value))
				{
					this.OnSubjectAssignmentIdChanging(value);
					this.SendPropertyChanging();
					this._SubjectAssignmentId = value;
					this.SendPropertyChanged("SubjectAssignmentId");
					this.OnSubjectAssignmentIdChanged();
				}
			}
		}
		
		[global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_SubjectId", DbType="Int NOT NULL")]
		public int SubjectId
		{
			get
			{
				return this._SubjectId;
			}
			set
			{
				if ((this._SubjectId != value))
				{
					if (this._Subject.HasLoadedOrAssignedValue)
					{
						throw new System.Data.Linq.ForeignKeyReferenceAlreadyHasValueException();
					}
					this.OnSubjectIdChanging(value);
					this.SendPropertyChanging();
					this._SubjectId = value;
					this.SendPropertyChanged("SubjectId");
					this.OnSubjectIdChanged();
				}
			}
		}
		
		[global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_UserId", DbType="NVarChar(50) NOT NULL", CanBeNull=false)]
		public string UserId
		{
			get
			{
				return this._UserId;
			}
			set
			{
				if ((this._UserId != value))
				{
					if (this._Student.HasLoadedOrAssignedValue)
					{
						throw new System.Data.Linq.ForeignKeyReferenceAlreadyHasValueException();
					}
					this.OnUserIdChanging(value);
					this.SendPropertyChanging();
					this._UserId = value;
					this.SendPropertyChanged("UserId");
					this.OnUserIdChanged();
				}
			}
		}
		
		[global::System.Data.Linq.Mapping.AssociationAttribute(Name="Subject_StudentSubject", Storage="_Subject", ThisKey="SubjectId", OtherKey="SubjectId", IsForeignKey=true)]
		public Subject Subject
		{
			get
			{
				return this._Subject.Entity;
			}
			set
			{
				Subject previousValue = this._Subject.Entity;
				if (((previousValue != value) 
							|| (this._Subject.HasLoadedOrAssignedValue == false)))
				{
					this.SendPropertyChanging();
					if ((previousValue != null))
					{
						this._Subject.Entity = null;
						previousValue.StudentSubjects.Remove(this);
					}
					this._Subject.Entity = value;
					if ((value != null))
					{
						value.StudentSubjects.Add(this);
						this._SubjectId = value.SubjectId;
					}
					else
					{
						this._SubjectId = default(int);
					}
					this.SendPropertyChanged("Subject");
				}
			}
		}
		
		[global::System.Data.Linq.Mapping.AssociationAttribute(Name="Student_StudentSubject", Storage="_Student", ThisKey="UserId", OtherKey="UserId", IsForeignKey=true)]
		public Student Student
		{
			get
			{
				return this._Student.Entity;
			}
			set
			{
				Student previousValue = this._Student.Entity;
				if (((previousValue != value) 
							|| (this._Student.HasLoadedOrAssignedValue == false)))
				{
					this.SendPropertyChanging();
					if ((previousValue != null))
					{
						this._Student.Entity = null;
						previousValue.StudentSubjects.Remove(this);
					}
					this._Student.Entity = value;
					if ((value != null))
					{
						value.StudentSubjects.Add(this);
						this._UserId = value.UserId;
					}
					else
					{
						this._UserId = default(string);
					}
					this.SendPropertyChanged("Student");
				}
			}
		}
		
		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));
			}
		}
	}
	
	[global::System.Data.Linq.Mapping.TableAttribute(Name="dbo.Students")]
	public partial class Student : INotifyPropertyChanging, INotifyPropertyChanged
	{
		
		private static PropertyChangingEventArgs emptyChangingEventArgs = new PropertyChangingEventArgs(String.Empty);
		
		private string _StudentId;
		
		private string _Name;
		
		private string _UserId;
		
		private EntitySet<StudentSubject> _StudentSubjects;
		
    #region Extensibility Method Definitions
    partial void OnLoaded();
    partial void OnValidate(System.Data.Linq.ChangeAction action);
    partial void OnCreated();
    partial void OnStudentIdChanging(string value);
    partial void OnStudentIdChanged();
    partial void OnNameChanging(string value);
    partial void OnNameChanged();
    partial void OnUserIdChanging(string value);
    partial void OnUserIdChanged();
    #endregion
		
		public Student()
		{
			this._StudentSubjects = new EntitySet<StudentSubject>(new Action<StudentSubject>(this.attach_StudentSubjects), new Action<StudentSubject>(this.detach_StudentSubjects));
			OnCreated();
		}
		
		[global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_StudentId", DbType="NVarChar(50) NOT NULL", CanBeNull=false)]
		public string StudentId
		{
			get
			{
				return this._StudentId;
			}
			set
			{
				if ((this._StudentId != value))
				{
					this.OnStudentIdChanging(value);
					this.SendPropertyChanging();
					this._StudentId = value;
					this.SendPropertyChanged("StudentId");
					this.OnStudentIdChanged();
				}
			}
		}
		
		[global::System.Data.Linq.Mapping.ColumnAttribute(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();
				}
			}
		}
		
		[global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_UserId", DbType="NVarChar(50) NOT NULL", CanBeNull=false, IsPrimaryKey=true)]
		public string UserId
		{
			get
			{
				return this._UserId;
			}
			set
			{
				if ((this._UserId != value))
				{
					this.OnUserIdChanging(value);
					this.SendPropertyChanging();
					this._UserId = value;
					this.SendPropertyChanged("UserId");
					this.OnUserIdChanged();
				}
			}
		}
		
		[global::System.Data.Linq.Mapping.AssociationAttribute(Name="Student_StudentSubject", Storage="_StudentSubjects", ThisKey="UserId", OtherKey="UserId")]
		public EntitySet<StudentSubject> StudentSubjects
		{
			get
			{
				return this._StudentSubjects;
			}
			set
			{
				this._StudentSubjects.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_StudentSubjects(StudentSubject entity)
		{
			this.SendPropertyChanging();
			entity.Student = this;
		}
		
		private void detach_StudentSubjects(StudentSubject entity)
		{
			this.SendPropertyChanging();
			entity.Student = null;
		}
	}
	
	[global::System.Data.Linq.Mapping.TableAttribute(Name="dbo.Questions")]
	public partial class Question : INotifyPropertyChanging, INotifyPropertyChanged
	{
		
		private static PropertyChangingEventArgs emptyChangingEventArgs = new PropertyChangingEventArgs(String.Empty);
		
		private int _QuestionId;
		
		private string _QuestionDetails;
		
		private int _ExamId;
		
		private EntityRef<Exam> _Exam;
		
    #region Extensibility Method Definitions
    partial void OnLoaded();
    partial void OnValidate(System.Data.Linq.ChangeAction action);
    partial void OnCreated();
    partial void OnQuestionIdChanging(int value);
    partial void OnQuestionIdChanged();
    partial void OnQuestionDetailsChanging(string value);
    partial void OnQuestionDetailsChanged();
    partial void OnExamIdChanging(int value);
    partial void OnExamIdChanged();
    #endregion
		
		public Question()
		{
			this._Exam = default(EntityRef<Exam>);
			OnCreated();
		}
		
		[global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_QuestionId", AutoSync=AutoSync.OnInsert, DbType="Int NOT NULL IDENTITY", IsPrimaryKey=true, IsDbGenerated=true)]
		public int QuestionId
		{
			get
			{
				return this._QuestionId;
			}
			set
			{
				if ((this._QuestionId != value))
				{
					this.OnQuestionIdChanging(value);
					this.SendPropertyChanging();
					this._QuestionId = value;
					this.SendPropertyChanged("QuestionId");
					this.OnQuestionIdChanged();
				}
			}
		}
		
		[global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_QuestionDetails", DbType="NVarChar(50) NOT NULL", CanBeNull=false)]
		public string QuestionDetails
		{
			get
			{
				return this._QuestionDetails;
			}
			set
			{
				if ((this._QuestionDetails != value))
				{
					this.OnQuestionDetailsChanging(value);
					this.SendPropertyChanging();
					this._QuestionDetails = value;
					this.SendPropertyChanged("QuestionDetails");
					this.OnQuestionDetailsChanged();
				}
			}
		}
		
		[global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_ExamId", DbType="Int NOT NULL")]
		public int ExamId
		{
			get
			{
				return this._ExamId;
			}
			set
			{
				if ((this._ExamId != value))
				{
					if (this._Exam.HasLoadedOrAssignedValue)
					{
						throw new System.Data.Linq.ForeignKeyReferenceAlreadyHasValueException();
					}
					this.OnExamIdChanging(value);
					this.SendPropertyChanging();
					this._ExamId = value;
					this.SendPropertyChanged("ExamId");
					this.OnExamIdChanged();
				}
			}
		}
		
		[global::System.Data.Linq.Mapping.AssociationAttribute(Name="Exam_Question", Storage="_Exam", ThisKey="ExamId", OtherKey="ExamId", IsForeignKey=true)]
		public Exam Exam
		{
			get
			{
				return this._Exam.Entity;
			}
			set
			{
				Exam previousValue = this._Exam.Entity;
				if (((previousValue != value) 
							|| (this._Exam.HasLoadedOrAssignedValue == false)))
				{
					this.SendPropertyChanging();
					if ((previousValue != null))
					{
						this._Exam.Entity = null;
						previousValue.Questions.Remove(this);
					}
					this._Exam.Entity = value;
					if ((value != null))
					{
						value.Questions.Add(this);
						this._ExamId = value.ExamId;
					}
					else
					{
						this._ExamId = default(int);
					}
					this.SendPropertyChanged("Exam");
				}
			}
		}
		
		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));
			}
		}
	}
}
#pragma warning restore 1591

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

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

License

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


Written By
Software Developer
India India
I am developer in .Net and GIS. albin_gis@yahoo.com

Comments and Discussions