コード例 #1
0
        private static void Main()
        {
            using (var flightManagerDbContext = new FlightManagerDbContext())
            {
                flightManagerDbContext.Database.Migrate();
                for (int i = 0; i < 10; ++i)
                {
                    flightManagerDbContext.Set <Aircraft>().Add(
                        new Aircraft()
                    {
                        Name = string.Concat("Aircraft ", i), Count = 5, InFlyFuelConsumption = (i * 158.99), InTakeOffFuelConsumption = (58.45 + i), PassengerCapacity = 200, MaxSpeed = "Not Defined"
                    }
                        );
                }

                Random random = new Random();
                for (int i = 0; i < 100; ++i)
                {
                    flightManagerDbContext.Set <Airport>().Add(
                        new Airport()
                    {
                        Name = string.Concat("Airport", i), Latitude = random.NextDouble(), Longitude = random.NextDouble()
                    }
                        );
                }

                flightManagerDbContext.SaveChanges();
            }
        }
コード例 #2
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="flightManagerDbContext">Db Context instanciate in the UnitOfWork</param>
 public Repository(FlightManagerDbContext flightManagerDbContext)
 {
     _flightManagerDbContext = flightManagerDbContext;
     _entities = flightManagerDbContext.Set <TEntity>();
 }