Skip to content

Commit 5a4747c

Browse files
update to dotnet9 and use query builder package
1 parent 7190a8e commit 5a4747c

File tree

5 files changed

+67
-98
lines changed

5 files changed

+67
-98
lines changed

NorthwindCRUD.Tests/NorthwindCRUD.Tests.csproj

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>net6.0</TargetFramework>
4+
<TargetFramework>net9.0</TargetFramework>
55
<ImplicitUsings>enable</ImplicitUsings>
66
<Nullable>enable</Nullable>
77

@@ -16,14 +16,20 @@
1616
</PropertyGroup>
1717

1818
<ItemGroup>
19-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.1.0" />
20-
<PackageReference Include="MSTest.TestAdapter" Version="2.2.8" />
21-
<PackageReference Include="MSTest.TestFramework" Version="2.2.8" />
19+
<PackageReference Include="AutoMapper" Version="14.0.0" />
20+
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="9.0.6">
21+
<PrivateAssets>all</PrivateAssets>
22+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
23+
</PackageReference>
24+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.14.1" />
25+
<PackageReference Include="MSTest.TestAdapter" Version="3.9.3" />
26+
<PackageReference Include="MSTest.TestFramework" Version="3.9.3" />
2227
<PackageReference Include="coverlet.collector" Version="3.1.2" />
2328
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118">
2429
<PrivateAssets>all</PrivateAssets>
2530
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
2631
</PackageReference>
32+
<PackageReference Include="System.Text.RegularExpressions" Version="4.3.1" />
2733

2834
</ItemGroup>
2935

NorthwindCRUD/Controllers/QueryBuilderController.cs

Lines changed: 0 additions & 75 deletions
This file was deleted.
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
using Newtonsoft.Json;
2+
using NorthwindCRUD.Models.Dtos;
3+
4+
namespace NorthwindCRUD.Models
5+
{
6+
public class QueryBuilderResult
7+
{
8+
[JsonProperty(NullValueHandling = NullValueHandling.Ignore)] public AddressDto[]? Addresses { get; set; }
9+
10+
[JsonProperty(NullValueHandling = NullValueHandling.Ignore)] public CategoryDto[]? Categories { get; set; }
11+
12+
[JsonProperty(NullValueHandling = NullValueHandling.Ignore)] public ProductDto[]? Products { get; set; }
13+
14+
[JsonProperty(NullValueHandling = NullValueHandling.Ignore)]public RegionDto[]? Regions { get; set; }
15+
16+
[JsonProperty(NullValueHandling = NullValueHandling.Ignore)] public TerritoryDto[]? Territories { get; set; }
17+
18+
[JsonProperty(NullValueHandling = NullValueHandling.Ignore)] public EmployeeDto[]? Employees { get; set; }
19+
20+
[JsonProperty(NullValueHandling = NullValueHandling.Ignore)] public CustomerDto[]? Customers { get; set; }
21+
22+
[JsonProperty(NullValueHandling = NullValueHandling.Ignore)] public OrderDto[]? Orders { get; set; }
23+
24+
[JsonProperty(NullValueHandling = NullValueHandling.Ignore)] public OrderDetailDto[]? OrderDetails { get; set; }
25+
26+
[JsonProperty(NullValueHandling = NullValueHandling.Ignore)] public ShipperDto[]? Shippers { get; set; }
27+
28+
[JsonProperty(NullValueHandling = NullValueHandling.Ignore)] public SupplierDto[]? Suppliers { get; set; }
29+
}
30+
}

NorthwindCRUD/NorthwindCRUD.csproj

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk.Web">
22

33
<PropertyGroup>
4-
<TargetFramework>net6.0</TargetFramework>
4+
<TargetFramework>net9.0</TargetFramework>
55
<Nullable>enable</Nullable>
66
<ImplicitUsings>enable</ImplicitUsings>
77

@@ -20,31 +20,32 @@
2020
</PropertyGroup>
2121

2222
<ItemGroup>
23-
<PackageReference Include="AutoMapper" Version="11.0.1" />
24-
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="11.0.0" />
23+
<PackageReference Include="AutoMapper" Version="14.0.0" />
2524
<PackageReference Include="BCrypt.Net-Next" Version="4.0.3" />
2625
<PackageReference Include="GraphQL.AspNet" Version="0.12.2-beta" />
27-
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="6.0.11" />
28-
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="6.0.8" />
29-
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="6.0.8">
26+
<PackageReference Include="Infragistics.QueryBuilder.Executor" Version="0.1.0-prerelease0002" />
27+
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="9.0.6" />
28+
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="9.0.6" />
29+
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="9.0.6">
3030
<PrivateAssets>all</PrivateAssets>
3131
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
3232
</PackageReference>
33-
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="6.0.11" />
34-
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="6.0.22" />
35-
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="6.0.8" />
36-
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="6.0.8">
33+
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="9.0.6" />
34+
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="9.0.6" />
35+
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="9.0.6" />
36+
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="9.0.6">
3737
<PrivateAssets>all</PrivateAssets>
3838
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
3939
</PackageReference>
40-
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="6.0.10" />
41-
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
42-
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.556">
40+
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="9.0.0" />
41+
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
42+
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118">
4343
<PrivateAssets>all</PrivateAssets>
4444
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
4545
</PackageReference>
46-
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.2.3" />
47-
<PackageReference Include="Swashbuckle.AspNetCore.Annotations" Version="6.5.0" />
46+
<PackageReference Include="Swashbuckle.AspNetCore" Version="9.0.1" />
47+
<PackageReference Include="Swashbuckle.AspNetCore.Annotations" Version="9.0.1" />
48+
<PackageReference Include="System.Text.RegularExpressions" Version="4.3.1" />
4849
</ItemGroup>
4950

5051
<ItemGroup>

NorthwindCRUD/Program.cs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
11
using System.Text;
2+
using System.Text.Json.Serialization;
23
using AutoMapper;
34
using GraphQL.AspNet.Configuration.Mvc;
5+
using Infragistics.QueryBuilder.Executor;
46
using Microsoft.AspNetCore.Authentication.JwtBearer;
7+
using Microsoft.EntityFrameworkCore;
58
using Microsoft.IdentityModel.Tokens;
69
using Microsoft.OpenApi.Models;
710
using Newtonsoft.Json;
811
using Newtonsoft.Json.Converters;
912
using NorthwindCRUD.Filters;
1013
using NorthwindCRUD.Helpers;
1114
using NorthwindCRUD.Middlewares;
15+
using NorthwindCRUD.Models;
1216
using NorthwindCRUD.Providers;
1317
using NorthwindCRUD.Services;
1418

@@ -80,15 +84,16 @@ public static void Main(string[] args)
8084
configurationProvider.ConfigureOptions(options);
8185
});
8286

83-
var config = new MapperConfiguration(cfg =>
87+
builder.Services.AddQueryBuilder<DataContext, QueryBuilderResult>();
88+
89+
var mapperConfig = new MapperConfiguration(static cfg =>
8490
{
8591
cfg.AddProfile(new MappingProfiles());
8692
});
87-
88-
var mapper = config.CreateMapper();
89-
93+
var mapper = mapperConfig.CreateMapper();
9094
builder.Services.AddSingleton(mapper);
9195

96+
9297
builder.Services.AddAuthentication(options =>
9398
{
9499
options.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme;
@@ -159,6 +164,8 @@ public static void Main(string[] args)
159164

160165
app.MapControllers();
161166

167+
app.UseEndpoints(endpoints => { endpoints.UseQueryBuilder<DataContext, QueryBuilderResult>("/QueryBuilder/ExecuteQuery"); });
168+
162169
app.Run();
163170
}
164171
}

0 commit comments

Comments
 (0)