Exemplo n.º 1
0
        static void InsertDrivers()
        {
            var drivers = new List <Driver>()
            {
                new Driver()
                {
                    firstName = "Alonso", lastName = "Hopkins", middleName = "Caleb",
                },
                new Driver()
                {
                    firstName = "Kaydence", lastName = "Sellers", middleName = "Susannah",
                },
                new Driver()
                {
                    firstName = "Finnegan", lastName = "Bray", middleName = "Brighton",
                },
            };

            using (var db = new gibddDbContext(_optionsBuilder.Options))
            {
                foreach (var driver in drivers)
                {
                    driver.LastModifiedUserId = 1;
                }
                db.AddRange(drivers);
                db.SaveChanges();
            }
        }
Exemplo n.º 2
0
 static void DeleteAllDrivers()
 {
     using (var db = new gibddDbContext(_optionsBuilder.Options))
     {
         var drivers = db.Drivers.ToList();
         foreach (var driver in drivers)
         {
             driver.LastModifiedUserId = 1;
         }
         db.Drivers.RemoveRange(drivers);
         db.SaveChanges();
     }
 }