コード例 #1
0
ファイル: Startup.cs プロジェクト: aamccarty/296Assignments
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, ApplicaitonDbContext context)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
                app.UseHsts();
            }

            app.UseHttpsRedirection();
            app.UseStaticFiles();
            app.UseCookiePolicy();

            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "default",
                    template: "{controller=Home}/{action=Index}/{id?}");
            });

            // Create or update the database and apply migrations.
            context.Database.Migrate();

            // Add a book and review or two as sample/test data.
            SeedData.Seed(context);
        }
コード例 #2
0
 //using dependency injeciton
 public CreateModel(ApplicaitonDbContext db)
 {
     _db = db;
 }
コード例 #3
0
 public Repository(ApplicaitonDbContext appDbContext)
 {
     context = appDbContext;
 }
コード例 #4
0
 //using dependency injeciton
 public IndexModel(ApplicaitonDbContext db)
 {
     _db = db;
 }