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