Exemple #1
0
 private static void removeAll()
 {
     using (EDModelContainer db = new EDModelContainer())
     {
         List <Course> CourseList = db.Courses.ToList();
         foreach (Course c in CourseList)
         {
             List <Student> StudentList = c.Students.ToList();
             foreach (Student s in StudentList)
             {
                 c.Students.Remove(s);
             }
             db.SaveChanges();
         }
     }
 }
Exemple #2
0
        private static void dropStudentFromCourse()
        {
            Console.Write("Student Number: ");
            string sNumber = Console.ReadLine();

            Console.Write("Course Code: ");
            string cCode = Console.ReadLine();

            using (EDModelContainer db = new EDModelContainer())
            {
                Student student = db.Students.Where(s => s.StudentNum == sNumber).First();
                Course  course  = db.Courses.Where(c => c.CourseCode == cCode).First();

                course.Students.Remove(student);
                db.SaveChanges();
            }
        }