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();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Indotalent.Infrastructure.OData;
|
||||
|
||||
public class ODataResponse<T>
|
||||
{
|
||||
[JsonPropertyName("value")]
|
||||
public List<T> Value { get; set; } = new();
|
||||
|
||||
[JsonPropertyName("@odata.count")]
|
||||
public int Count { get; set; }
|
||||
}
|
||||
Reference in New Issue
Block a user