コード例 #1
0
 public void AddStudent(Student s)
 {
     using (StudentsEntities context = new StudentsEntities())
     {
         context.Students.Add(s);
         context.SaveChanges();
     }
 }
コード例 #2
0
 public void DeleteStudentById(string id)
 {
     using (StudentsEntities context = new StudentsEntities())
     {
         foreach (Student s in context.Students)
         {
             if (s.Id == id)
             {
                 context.Students.Remove(s);
             }
         }
         context.SaveChanges();
     }
 }