コード例 #1
0
 public void AddTimeslot(TimeSlot slot)
 {
     using (GymContext db = new GymContext())
     {
         try
         {
             // add and save
             db.TimeSlots.Add(slot);
             db.SaveChanges();
         }
         catch (Exception e)
         {
             Console.WriteLine(e.ToString());
         }
     }
 }
コード例 #2
0
 public void AddTrainer(Trainer trainer)
 {
     using (GymContext db = new GymContext())
     {
         try
         {
             // add and save
             db.Trainers.Add(trainer);
             db.SaveChanges();
             // navigation properties updated on both sides
         }
         catch (Exception e)
         {
             Console.WriteLine(e.ToString());
         }
     }
 }