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();
 }
 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();
 }
Beispiel #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();
        }
Beispiel #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();
        }