Ejemplo n.º 1
0
 public void AddRace(Race race)
 {
     using (HorseEntities db = new HorseEntities())
     {
         db.Races.Add(race);
         db.SaveChanges();
     }
 }
Ejemplo n.º 2
0
 public void Add(Horse horse)
 {
     using (HorseEntities db = new HorseEntities())
     {
         db.Horses.Add(horse);
         db.SaveChanges();
     }
 }
Ejemplo n.º 3
0
        private Horse GetHorse(String name)
        {
            using (HorseEntities db = new HorseEntities())
            {
                Horse horse = db.Horses.FirstOrDefault(h => h.Name == name);

                if (horse == null)
                {
                    horse      = new Horse();
                    horse.Name = name;
                    db.Horses.Add(horse);
                    db.SaveChanges();

                    return(horse);
                }
                else
                {
                    return(horse);
                }
            }
        }