public void InsertStudentLectureAssociations() { Student Carla = dataContext.Students.First(st => st.Name.Equals("Carla")); Student Tony = dataContext.Students.First(st => st.Name.Equals("Tony")); Student Samantha = dataContext.Students.First(st => st.Name.Equals("Samantha")); Student Sam = dataContext.Students.First(st => st.Name.Equals("Sam")); Student James = dataContext.Students.First(st => st.Name.Equals("James")); Lecture Mathamatics = dataContext.Lectures.First(lc => lc.Name.Equals("Mathamatics")); Lecture History = dataContext.Lectures.First(lc => lc.Name.Equals("History")); // this way dataContext.StudentLectures.InsertOnSubmit(new StudentLecture { Student = Carla, Lecture = Mathamatics }); dataContext.StudentLectures.InsertOnSubmit(new StudentLecture { Student = Tony, Lecture = History }); // or this way StudentLecture slSamantha = new StudentLecture { Student = Samantha, LectureId = Mathamatics.Id }; dataContext.StudentLectures.InsertOnSubmit(slSamantha); StudentLecture slSam = new StudentLecture { Student = Sam, LectureId = History.Id }; dataContext.StudentLectures.InsertOnSubmit(slSam); dataContext.StudentLectures.InsertOnSubmit(new StudentLecture { Student = James, Lecture = Mathamatics }); 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);