Beispiel #1
0
 public ProductRepository(MyRestApiContext context)
 {
     _context          = context;
     _deepProductQuery = _context.Products
                         .Include(product => product.Category)
                         .Include(product => product.Comments)
                         .Include(product => product.TagProducts)
                         .ThenInclude(tagProduct => tagProduct.Tag)
                         .Include(product => product.Features);
 }
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            app.UseRouting();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllers();
            });

            var scoppedFactory = app.ApplicationServices.GetRequiredService <IServiceScopeFactory>();

            using (var scope = scoppedFactory.CreateScope())
            {
                MyRestApiContext
                .Seed(scope.ServiceProvider)
                .Wait();
            }
        }