예제 #1
0
 static void addRabbit()
 {
     using (var db = new RabbitDbContext())
     {
         var rabbit = new Rabbit(3, "Rabbit3", 0);
         // add to database
         db.Rabbits.Add(rabbit);
         db.SaveChanges();
     }
 }
예제 #2
0
        static Rabbit NewRabbit()
        {
            var    rn = new PersonNameGenerator();
            Rabbit r  = new Rabbit()
            {
                RabbitName = rn.GenerateRandomFirstName(),
                RabbitAge  = 0
            };

            return(r);
        }
예제 #3
0
 static void addRabbit(DbContext db)
 {
     foreach (Rabbit i in rabbits)
     {
         if (i.RabbitAge > 2)
         {
             Rabbit r = NewRabbit();
             db.Add(r);
         }
     }
     db.SaveChanges();
 }