Ejemplo n.º 1
0
        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;
        }
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);