Exemple #1
0
        static void PrintRabbits()
        {
            using (var db = new RabbitDbContext())
            {
                Rabbits = db.Rabbits.ToList();
            }

            Rabbits.ForEach(c => Console.WriteLine($"{c.RabbitID,-10}{c.RabbitName,-30}{c.RabbitAge,-40}"));
        }
Exemple #2
0
 static void updateRabbits(int rabbitID)
 {
     using (var db = new RabbitDbContext())
     {
         var rabbit = db.Rabbits.Find(rabbitID);
         rabbit.RabbitAge++;
         db.Rabbits.Update(rabbit);
         db.SaveChanges();
     }
 }
Exemple #3
0
 static void updateRabbitAge()
 {
     using (var db = new RabbitDbContext())
     {
         Rabbits = db.Rabbits.ToList();
         foreach (var age in Rabbits)
         {
             age.RabbitAge++;
             db.Rabbits.Update(age);
         }
         db.SaveChanges();
     }
 }
Exemple #4
0
 static void addRabbits()
 {
     using (var db = new RabbitDbContext())
     {
         for (int i = 0; i < 10; i++)
         {
             var rabbit = new Rabbit("Rabbit" + i, 0);
             db.Rabbits.Add(rabbit);
             updateRabbitAge();
         }
         db.SaveChanges();
     }
 }