コード例 #1
0
 protected void Button1_Click(object sender, EventArgs e)
 {
     StudentDBContext studentDBContext = new StudentDBContext();
     studentDBContext.StudentCourses.Add(new StudentCourse
     { StudentID = 1, CourseID = 4, EnrolledDate = DateTime.Now });
     studentDBContext.SaveChanges();
 }
コード例 #2
0
 protected void Button2_Click(object sender, EventArgs e)
 {
     StudentDBContext studentDBContext = new StudentDBContext();
     StudentCourse studentCourseToRemove = studentDBContext.StudentCourses
        .FirstOrDefault(x => x.StudentID == 2 && x.CourseID == 3);
     studentDBContext.StudentCourses.Remove(studentCourseToRemove);
     studentDBContext.SaveChanges();
 }
コード例 #3
0
        protected void Button2_Click(object sender, EventArgs e)
        {
            StudentDBContext studentDBContext      = new StudentDBContext();
            StudentCourse    studentCourseToRemove = studentDBContext.StudentCourses
                                                     .FirstOrDefault(x => x.StudentID == 2 && x.CourseID == 3);

            studentDBContext.StudentCourses.Remove(studentCourseToRemove);
            studentDBContext.SaveChanges();
        }
コード例 #4
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            StudentDBContext studentDBContext = new StudentDBContext();

            studentDBContext.StudentCourses.Add(new StudentCourse
            {
                StudentID = 1, CourseID = 4, EnrolledDate = DateTime.Now
            });
            studentDBContext.SaveChanges();
        }