initial commit
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
using Indotalent.Data.Entities;
|
||||
using Indotalent.Shared.Consts;
|
||||
using Microsoft.AspNetCore.OData;
|
||||
using Microsoft.OData.Edm;
|
||||
using Microsoft.OData.ModelBuilder;
|
||||
|
||||
namespace Indotalent.Infrastructure.OData;
|
||||
|
||||
public static class DI
|
||||
{
|
||||
public static IServiceCollection AddODataService(this IServiceCollection services)
|
||||
{
|
||||
services.AddControllers().AddOData(options =>
|
||||
{
|
||||
options.AddRouteComponents("odata", GetEdmModel())
|
||||
.Select()
|
||||
.Filter()
|
||||
.OrderBy()
|
||||
.Expand()
|
||||
.Count()
|
||||
.SetMaxTop(GlobalConsts.ODataMaxTop);
|
||||
});
|
||||
|
||||
return services;
|
||||
}
|
||||
|
||||
private static IEdmModel GetEdmModel()
|
||||
{
|
||||
var builder = new ODataConventionModelBuilder();
|
||||
|
||||
builder.EntitySet<SerilogLogs>("SerilogLogs");
|
||||
|
||||
return builder.GetEdmModel();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user