示例#1
0
 public static void Delete(int id)
 {
     using (TrainingContext db = new TrainingContext())
     {
         Team newTeam = db.Teams.Find(id);
         db.Teams.Remove(newTeam);
         db.SaveChanges();
     }
 }
示例#2
0
        public static void Update(int id, string name)
        {
            using (TrainingContext db = new TrainingContext())
            {
                Team newTeam = db.Teams.Find(id);
                newTeam.Id   = id;
                newTeam.Name = name;

                db.Teams.Update(newTeam);
                db.SaveChanges();
            }
        }
示例#3
0
        public static void Insert(int id, string name)
        {
            using (TrainingContext db = new TrainingContext())
            {
                Team newTeam = new Team();
                newTeam.Id   = id;
                newTeam.Name = name;

                db.Teams.Add(newTeam);
                db.SaveChanges();
            }
        }