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