Пример #1
0
 public void TestStoreBrand()
 {
     using (TransactionScope ts = new TransactionScope())
     using (CarsContext context = new CarsContext())
     {
         Brand volvo = new Brand { Name = "Volvo" };
         context.Brands.Add(volvo);
         context.SaveChanges();
     }
 }
Пример #2
0
        public void TestStoreCar()
        {
            using (TransactionScope ts = new TransactionScope())
            using (CarsContext context = new CarsContext())
            {
                Brand volvo = new Brand { Name = "Volvo" };
                Car myVolvo = new Car
                {
                    Brand = volvo,
                    RegistrationNumber = "ABC123"
                };

                context.Cars.Add(myVolvo);
                context.SaveChanges();
            }
        }