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