public void AssociateStudentWithLecture()
        {
            Student carla = dataContext.Students.First(stu => stu.Name.Equals("Carla"));
            Student toni  = dataContext.Students.First(stu => stu.Name.Equals("Toni"));
            Student leyla = dataContext.Students.First(stu => stu.Name.Equals("Leyla"));
            Student james = dataContext.Students.First(stu => stu.Name.Equals("James"));

            Lecture maths   = dataContext.Lectures.First(lec => lec.Name.Equals("Maths"));
            Lecture history = dataContext.Lectures.First(lec => lec.Name.Equals("History"));

            dataContext.StudentLectures.InsertOnSubmit(new StudentLecture {
                Student = carla, Lecture = maths
            });
            dataContext.StudentLectures.InsertOnSubmit(new StudentLecture {
                Student = toni, Lecture = maths
            });

            StudentLecture slToni = new StudentLecture();

            slToni.Student   = toni;
            slToni.LectureId = history.Id;
            dataContext.StudentLectures.InsertOnSubmit(slToni);
            dataContext.StudentLectures.InsertOnSubmit(new StudentLecture {
                Student = leyla, Lecture = history
            });
            dataContext.StudentLectures.InsertOnSubmit(new StudentLecture {
                Student = james, Lecture = maths
            });
            dataContext.SubmitChanges();

            MainDataGrid.ItemsSource = dataContext.StudentLectures;
        }
 private void detach_StudentLectures(StudentLecture entity)
 {
     this.SendPropertyChanging();
     entity.Lecture = null;
 }
 private void attach_StudentLectures(StudentLecture entity)
 {
     this.SendPropertyChanging();
     entity.Lecture = this;
 }
 partial void DeleteStudentLecture(StudentLecture instance);
 partial void UpdateStudentLecture(StudentLecture instance);
 partial void InsertStudentLecture(StudentLecture instance);