Created
April 15, 2019 01:57
-
-
Save adlerpagliarini/b137c6926a21d340f1b2d773606cdf91 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 void Configure(IApplicationBuilder app, IHostingEnvironment env) | |
{ | |
... | |
app.UseMvc(routerBuilder => | |
{ | |
// 2. Enable Dependency Injection on current routes | |
routerBuilder.EnableDependencyInjection(builder => | |
{ | |
var modelConfig = ODataEntitiesConfiguration.GetEdmModel(app.ApplicationServices); | |
builder | |
.AddService(Microsoft.OData.ServiceLifetime.Singleton, typeof(IEdmModel), sp => modelConfig) | |
.AddService(Microsoft.OData.ServiceLifetime.Singleton, typeof(ODataUriResolver), sp => new StringAsEnumResolver()) | |
.AddService(Microsoft.OData.ServiceLifetime.Singleton, typeof(ODataUriResolver), sp => new UnqualifiedCallAndEnumPrefixFreeResolver { EnableCaseInsensitive = true }); | |
}); | |
// 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