Last active
April 15, 2019 01:00
-
-
Save adlerpagliarini/ca65d2556ab202082823bf127a1ad686 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 class Startup | |
{ | |
public Startup(IConfiguration configuration) | |
{ | |
Configuration = configuration; | |
} | |
public IConfiguration Configuration { get; } | |
public void ConfigureServices(IServiceCollection services) | |
{ | |
services.AddDbContext<DatabaseContext>(); | |
services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2); | |
// 1. Add o Data service | |
services.AddOData(); | |
} | |
public void Configure(IApplicationBuilder app, IHostingEnvironment env) | |
{ | |
if (env.IsDevelopment()) | |
{ | |
app.UseDeveloperExceptionPage(); | |
} | |
else | |
{ | |
app.UseHsts(); | |
} | |
app.UseHttpsRedirection(); | |
app.UseMvc(routerBuilder => | |
{ | |
// 2. Enable Dependency Injection on current routes | |
routerBuilder.EnableDependencyInjection(); | |
// 3. Enable OData operations for all entities | |
routerBuilder.Select().Filter().OrderBy().Expand().MaxTop(null); | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment