Пример #1
0
        private static void AddCar()
        {
            var context = new CarDealershipContext();

            try
            {
                var car = new Car
                {
                    Brand              = "Tesla",
                    Model              = "ModelX",
                    Engine             = 2.0,
                    TypeOfCar          = "Electric",
                    HorsePower         = 600,
                    HasElectricWindows = true,
                    HasNavigation      = true
                };

                context.CarContext.Add(car);
                context.SaveChanges();
            }
            finally
            {
                context.Dispose();
            }
        }
Пример #2
0
        static void Main(string[] args)
        {
            context.Database.EnsureCreated();
            context.Database.Migrate();


            IRepository <Car> studentRepository = new EntityFrameworkRepository <Car>();

            studentRepository.Insert(
                new Car
            {
                Brand              = "Tesla",
                Model              = "ModelX",
                Engine             = 2.0,
                TypeOfCar          = "Electric",
                HorsePower         = 600,
                HasElectricWindows = true,
                HasNavigation      = true
            });

            AddCar();
            ReadCar();
            ChangeCar();
            DeleteCar();

            context.Dispose();
        }