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;
        }
Example #2
0
 private void detach_StudentLectures(StudentLecture entity)
 {
     this.SendPropertyChanging();
     entity.Lecture = null;
 }
Example #3
0
 private void attach_StudentLectures(StudentLecture entity)
 {
     this.SendPropertyChanging();
     entity.Lecture = this;
 }
Example #4
0
 partial void DeleteStudentLecture(StudentLecture instance);
Example #5
0
 partial void UpdateStudentLecture(StudentLecture instance);
Example #6
0
 partial void InsertStudentLecture(StudentLecture instance);