public void InsertStudentLecturesAssociation() { Student Carla = dataContext.Students.First(st => st.Name.Equals("Carla")); Student Tony = dataContext.Students.First(st => st.Name.Equals("Tony")); Student Layla = dataContext.Students.First(st => st.Name.Equals("Layla")); 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 }); // Connecting the object Carla and the object math dataContext.StudentLectures.InsertOnSubmit(new StudentLecture { Student = Tony, Lecture = Math }); // Could also do like this, but more old school StudentLecture slToni = new StudentLecture(); slToni.LectureId = History.Id; slToni.StudentId = Tony.Id; dataContext.StudentLectures.InsertOnSubmit(slToni); dataContext.StudentLectures.InsertOnSubmit(new StudentLecture { Student = Layla, 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);