Last active
April 3, 2019 11:18
-
-
Save ibrahimozgon/d4d8884aa703b8aa95d8fee2092e0d24 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void ConfigureServices(IServiceCollection services) | |
{ | |
services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2); | |
//1 | |
//services.AddDbContext<MyDbContext>(options => { options.UseInMemoryDatabase(Guid.NewGuid().ToString()); }); | |
services.AddDbContext<MyDbContext>(options => | |
{ | |
options.UseSqlServer(@"Server=localhost\SQLEXPRESS;Database=ODataTest;Trusted_Connection=True;"); | |
}); | |
//2 | |
services.AddOData(); | |
} | |
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory, MyDbContext myDbContext) | |
{ | |
//3 | |
loggerFactory.AddDebug(); | |
if (env.IsDevelopment()) | |
{ | |
app.UseDeveloperExceptionPage(); | |
} | |
else | |
{ | |
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. | |
app.UseHsts(); | |
} | |
app.UseHttpsRedirection(); | |
//4 | |
app.UseMvc(routeBuilder => | |
{ | |
routeBuilder.EnableDependencyInjection(); | |
routeBuilder.Expand().Filter().Select().Count().MaxTop(10).OrderBy(); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment