-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProgram.cs
36 lines (29 loc) · 1.07 KB
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
using Microsoft.AspNetCore.OData;
using Microsoft.Azure.Cosmos;
using Microsoft.Azure.Cosmos.Fluent;
using Microsoft.OData.ModelBuilder;
using U4PIM.InvoiceManagementAPI.Services;
using WebApplication1.Models;
var builder = WebApplication.CreateBuilder(args);
var modelBuilder = new ODataConventionModelBuilder();
modelBuilder.EntitySet<Customer>("Customers");
builder.Services
.AddSingleton((s) =>
{
return new CosmosClientBuilder("AccountEndpoint=https://localhost:8081/;AccountKey=C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw==")
.WithSerializerOptions(new CosmosSerializationOptions { PropertyNamingPolicy = CosmosPropertyNamingPolicy.CamelCase })
.Build();
})
.AddSingleton<ICosmosService, CosmosService>()
.AddControllers()
.AddOData(options => options
.EnableQueryFeatures()
.AddRouteComponents(
modelBuilder.GetEdmModel()
)
);
var app = builder.Build();
app
.UseRouting()
.UseEndpoints(endpoints => endpoints.MapControllers());
app.Run();