35 lines
909 B
C#
35 lines
909 B
C#
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();
|
|
}
|
|
} |