public void InsertStudentLectureAssociations() { Student Carla = dataContext.Students.First(st => st.Name.Equals("Carla")); Student Toni = dataContext.Students.First(st => st.Name.Equals("Toni")); Student Leyle = dataContext.Students.First(st => st.Name.Equals("Leyle")); Student Jame = dataContext.Students.First(st => st.Name.Equals("Jame")); 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 }); StudentLecture slToni = new StudentLecture(); slToni.StudentId = Toni.Id; slToni.LectureId = History.Id; dataContext.StudentLectures.InsertOnSubmit(slToni); dataContext.StudentLectures.InsertOnSubmit(new StudentLecture { Student = Leyle, Lecture = History }); dataContext.SubmitChanges(); MainDataGrid.ItemsSource = dataContext.StudentLectures; }
public void InsertStudentLectureAssociations() { Student Carla = dataContext.Students.First(st => st.Name.Equals("Carla")); Student Tonie = dataContext.Students.First(st => st.Name.Equals("Tonie")); Student Leyle = dataContext.Students.First(st => st.Name.Equals("Leyle")); Student Jame = dataContext.Students.First(st => st.Name.Equals("Jame")); Lecture Math = dataContext.Lectures.First(lec => lec.Name.Equals("Math")); Lecture History = dataContext.Lectures.First(lec => lec.Name.Equals("History")); dataContext.StudentLectures.InsertOnSubmit(new StudentLecture { Student = Carla, Lecture = Math }); dataContext.StudentLectures.InsertOnSubmit(new StudentLecture { Student = Tonie, Lecture = Math }); // below is another way of inserting data on a associative table StudentLecture slTonie = new StudentLecture(); slTonie.Student = Tonie; slTonie.LectureId = History.Id; dataContext.StudentLectures.InsertOnSubmit(slTonie); dataContext.StudentLectures.InsertOnSubmit(new StudentLecture { Student = Leyle, Lecture = History }); dataContext.SubmitChanges(); MainDataGrid.ItemsSource = dataContext.StudentLectures; }
public void InsertStudentLectureAssociations() { dataContext.ExecuteCommand("delete from StudentLecture"); Student Carla = dataContext.Students.First(st => st.Name.Equals("Carla")); Student Tonie = dataContext.Students.First(st => st.Name.Equals("Tonie")); 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")); Lecture Chemistry = dataContext.Lectures.First(lc => lc.Name.Equals("Chemistry")); Lecture Physics = dataContext.Lectures.First(lc => lc.Name.Equals("Physics")); Lecture Programming = dataContext.Lectures.First(lc => lc.Name.Equals("Programming")); dataContext.StudentLectures.InsertOnSubmit(new StudentLecture() { Student = Carla, Lecture = Math }); dataContext.StudentLectures.InsertOnSubmit(new StudentLecture() { Student = Tonie, Lecture = Math }); StudentLecture slTonie = new StudentLecture(); slTonie.Student = Tonie; slTonie.LectureId = History.Id; dataContext.StudentLectures.InsertOnSubmit(slTonie); dataContext.StudentLectures.InsertOnSubmit(new StudentLecture() { Student = Leyla, Lecture = Chemistry }); 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);