Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 5 additions & 8 deletions CS/ODataService/Controllers/ActionsController.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Linq;
using DevExpress.Xpo;
using Microsoft.AspNet.OData;
using Microsoft.AspNet.OData.Routing;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.OData.Routing.Controllers;
using Microsoft.AspNetCore.OData.Routing.Attributes;
using ODataService.Helpers;
using ODataService.Models;

Expand All @@ -16,15 +13,15 @@ public class ActionsController : ODataController {
public ActionsController(UnitOfWork uow) {
this.Session = uow;
}
[ODataRoute("InitializeDatabase")]
[Route("odata/InitializeDatabase")]
public IActionResult InitializeDatabase() {
DemoDataHelper.CleanupDatabase(Session);
DemoDataHelper.CreateDemoData(Session);
return Ok();
}

[HttpGet]
[ODataRoute("TotalSalesByYear(year={year})")]
[Route("odata/TotalSalesByYear(year={year})")]
public IActionResult TotalSalesByYear(int year) {
decimal result = Session.Query<Order>()
.Where(o => o.Date.Value.Year == year)
Expand Down
6 changes: 5 additions & 1 deletion CS/ODataService/Controllers/ContractController.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
using System;
using System.Linq;
using DevExpress.Xpo;
using Microsoft.AspNet.OData;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.OData.Deltas;
using Microsoft.AspNetCore.OData.Formatter;
using Microsoft.AspNetCore.OData.Query;
using Microsoft.AspNetCore.OData.Results;
using Microsoft.AspNetCore.OData.Routing.Controllers;
using ODataService.Helpers;
using ODataService.Models;

Expand Down
6 changes: 5 additions & 1 deletion CS/ODataService/Controllers/CustomerController.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
using System;
using System.Linq;
using DevExpress.Xpo;
using Microsoft.AspNet.OData;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.OData.Deltas;
using Microsoft.AspNetCore.OData.Formatter;
using Microsoft.AspNetCore.OData.Query;
using Microsoft.AspNetCore.OData.Results;
using Microsoft.AspNetCore.OData.Routing.Controllers;
using ODataService.Helpers;
using ODataService.Models;

Expand Down
5 changes: 4 additions & 1 deletion CS/ODataService/Controllers/DocumentsController.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
using System;
using System.Linq;
using DevExpress.Xpo;
using Microsoft.AspNet.OData;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.OData.Formatter;
using Microsoft.AspNetCore.OData.Query;
using Microsoft.AspNetCore.OData.Results;
using Microsoft.AspNetCore.OData.Routing.Controllers;
using ODataService.Helpers;
using ODataService.Models;

Expand Down
9 changes: 6 additions & 3 deletions CS/ODataService/Controllers/OrderController.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
using System;
using System.Linq;
using DevExpress.Xpo;
using Microsoft.AspNet.OData;
using Microsoft.AspNet.OData.Routing;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.OData.Deltas;
using Microsoft.AspNetCore.OData.Formatter;
using Microsoft.AspNetCore.OData.Query;
using Microsoft.AspNetCore.OData.Results;
using Microsoft.AspNetCore.OData.Routing.Controllers;
using ODataService.Helpers;
using ODataService.Models;

Expand Down Expand Up @@ -100,7 +103,7 @@ public IActionResult Patch([FromODataUri] int key, Delta<Order> order) {

[HttpPost]
[HttpPut]
[ODataRoute("Order({key})/OrderDetails")]
[Route("Order({key})/OrderDetails")]
public IActionResult AddToOrderDetails([FromODataUri] int key, OrderDetail orderDetail) {
Order order = Session.GetObjectByKey<Order>(key);
if(order == null) {
Expand Down
6 changes: 5 additions & 1 deletion CS/ODataService/Controllers/OrderDetailController.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
using System.Linq;
using DevExpress.Xpo;
using Microsoft.AspNet.OData;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.OData.Deltas;
using Microsoft.AspNetCore.OData.Formatter;
using Microsoft.AspNetCore.OData.Query;
using Microsoft.AspNetCore.OData.Results;
using Microsoft.AspNetCore.OData.Routing.Controllers;
using ODataService.Helpers;
using ODataService.Models;

Expand Down
6 changes: 5 additions & 1 deletion CS/ODataService/Controllers/ProductController.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
using System;
using System.Linq;
using DevExpress.Xpo;
using Microsoft.AspNet.OData;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.OData.Deltas;
using Microsoft.AspNetCore.OData.Formatter;
using Microsoft.AspNetCore.OData.Query;
using Microsoft.AspNetCore.OData.Results;
using Microsoft.AspNetCore.OData.Routing.Controllers;
using ODataService.Helpers;
using ODataService.Models;

Expand Down
2 changes: 1 addition & 1 deletion CS/ODataService/Helpers/ApiHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
using System.Collections;
using System.Net;
using DevExpress.Xpo;
using Microsoft.AspNet.OData;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.OData.Deltas;

namespace ODataService.Helpers {
public static class ApiHelper {
Expand Down
5 changes: 0 additions & 5 deletions CS/ODataService/Helpers/UriHelper.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.AspNet.OData;
using Microsoft.AspNet.OData.Extensions;
using Microsoft.AspNet.OData.Routing;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc.Routing;
using Microsoft.OData.UriParser;
using ODataService.Models;

Expand Down
4 changes: 1 addition & 3 deletions CS/ODataService/Models/SingletonEdmModel.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
using DevExpress.Data.Filtering;
using DevExpress.Xpo;
using DevExpress.Xpo.Metadata;
using Microsoft.AspNet.OData.Builder;
using Microsoft.OData.Edm;
using Microsoft.OData.ModelBuilder;
using ODataService.Helpers;
using System;
using System.Collections.Generic;
using System.Linq;

namespace ODataService.Models {
Expand Down
10 changes: 5 additions & 5 deletions CS/ODataService/ODataService.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
<TargetFramework>net8.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="DevExpress.Xpo" Version="24.2.6" />
<PackageReference Include="Microsoft.AspNetCore.OData" Version="7.7.8" />
<PackageReference Include="DevExpress.Xpo" Version="25.1.4" />
<PackageReference Include="Microsoft.AspNetCore.OData" Version="9.3.2" />
<PackageReference Include="Microsoft.Data.SqlClient" Version="5.2.2" />
<PackageReference Include="System.Configuration.ConfigurationManager" Version="8.0.1" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.10.0"/>
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="4.10.0"/>
<PackageReference Include="Microsoft.CodeAnalysis.Workspaces.MSBuild" Version="4.10.0"/>
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.10.0" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="4.10.0" />
<PackageReference Include="Microsoft.CodeAnalysis.Workspaces.MSBuild" Version="4.10.0" />
</ItemGroup>
</Project>
33 changes: 17 additions & 16 deletions CS/ODataService/Startup.cs
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
using System;
using System.Linq;
using DevExpress.Xpo.DB;
using Microsoft.AspNet.OData.Batch;
using Microsoft.AspNet.OData.Extensions;
using DevExpress.Xpo.DB;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.ModelBinding.Validation;
using Microsoft.AspNetCore.OData;
using Microsoft.AspNetCore.OData.Batch;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using ODataService.Helpers;
using ODataService.Models;
using System;
using System.Linq;

namespace ODataService
{
Expand All @@ -27,12 +26,15 @@ public Startup(IConfiguration configuration)
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
services.AddOData();
services.AddODataQueryFilter();
services.AddMvc(options => {
options.EnableEndpointRouting = false;
options.ModelValidatorProviders.Clear();
});
services.AddControllers()
.AddOData(opt => opt
.Select()
.Filter()
.OrderBy()
.Expand()
.Count()
.SetMaxTop(null)
.AddRouteComponents("odata", SingletonEdmModel.GetEdmModel()));

services.AddSingleton<IObjectModelValidator, CustomModelValidator>();

Expand All @@ -50,12 +52,11 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
app.UseDeveloperExceptionPage();
}

app.UseODataBatching();
app.UseRouting();

app.UseMvc(b =>
app.UseEndpoints(endpoints =>
{
b.Count().Filter().OrderBy().Expand().Select().MaxTop(null);
b.MapODataServiceRoute("odata", "odata", SingletonEdmModel.GetEdmModel(), new DefaultODataBatchHandler());
endpoints.MapControllers();
});
}
}
Expand Down