chore: Konfigurierte OData-Konvention Model Builder
This commit is contained in:
parent
c70257bb28
commit
9473ad7619
@ -1,7 +1,27 @@
|
||||
using DigitalData.Swagger.MockAPI.Dtos;
|
||||
using DigitalData.Swagger.MockAPI.Repos;
|
||||
using Microsoft.AspNetCore.OData;
|
||||
using Microsoft.OData.ModelBuilder;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
var config = builder.Configuration;
|
||||
|
||||
// Add services to the container.
|
||||
builder.Services.AddSingleton<ICompanyRepo, CompanyRepo>();
|
||||
|
||||
ODataConventionModelBuilder oDataModelbuilder = new();
|
||||
oDataModelbuilder.EntitySet<Company>("Companies");
|
||||
|
||||
builder.Services.AddControllers()
|
||||
.AddOData(options => options
|
||||
.AddRouteComponents("odata", oDataModelbuilder.GetEdmModel())
|
||||
.Select()
|
||||
.Filter()
|
||||
.OrderBy()
|
||||
.SetMaxTop(20)
|
||||
.Count()
|
||||
.Expand()
|
||||
);
|
||||
|
||||
builder.Services.AddControllers();
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user