public void InsertStudentLectureAssociations() { Student Carla = dataContext.Students.First(st => st.Name.Equals("Carla")); Student Toni = dataContext.Students.First(st => st.Name.Equals("Toni")); Student Leyla = dataContext.Students.First(st => st.Name.Equals("Leyla")); Student James = dataContext.Students.First(st => st.Name.Equals("James")); Lecture Math = dataContext.Lectures.First(lc => lc.Name.Equals("Math")); Lecture History = dataContext.Lectures.First(lc => lc.Name.Equals("History")); dataContext.StudentLectures.InsertOnSubmit(new StudentLecture { Student = Carla, Lecture = Math }); dataContext.StudentLectures.InsertOnSubmit(new StudentLecture { Student = Toni, Lecture = Math }); // Another way to insert 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.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);