示例#1
0
        protected override void Seed(CarRentalService.DAL.CarsContext context)
        {
            CarsInitializer.SeedCars(context);
            //  This method will be called after migrating to the latest version.

            //  You can use the DbSet<T>.AddOrUpdate() helper extension method
            //  to avoid creating duplicate seed data.
        }
示例#2
0
        public static void Main(string[] args)
        {
            var host = CreateWebHostBuilder(args).Build();

            using (var scope = host.Services.CreateScope())
            {
                var services = scope.ServiceProvider;
                try
                {
                    var context = services.GetRequiredService <AppDbContext>();
                    context.Database.Migrate();
                    CarsInitializer.Initialize(context);
                }
                catch
                {
                }
            }

            host.Run();
        }
示例#3
0
        static void Main(string[] args)
        {
            List <Car>       cars             = CarsInitializer.FillCars(new Car());
            Func <int, bool> hasValueAboveTwo = v => v > 2;

            var carsFiltered = cars.Select(x => new
            {
                x.Cars,
                x.Name
            })
                               .Select(c => new
            {
                c.Name
            });

            foreach (var car in carsFiltered)
            {
                foreach (var carList in car)
                {
                }
            }

            Console.ReadKey();
        }