Skip to content

Commit

Permalink
Refactor database selection and centralize package management
Browse files Browse the repository at this point in the history
The code was changed to improve the way different databases are selected by changing "useMSSQL" and "usePOSTGRE" to "mssql" and "postgre", and adjusting the related conditions. Additionally, all package references for the Api project have been centralized into a new Directory.Packages.props file to simplify management and enhance consistency. A few redundant import lines in ModelConfiguration have also been removed.
  • Loading branch information
Gary Woodfine committed Jan 19, 2024
1 parent 6981f3a commit 93384aa
Show file tree
Hide file tree
Showing 8 changed files with 52 additions and 37 deletions.
6 changes: 3 additions & 3 deletions src/Database/.template.config/template.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@
"dataType": "string",
"defaultValue": "Threenine"
},
"useMSSQL": {
"mssql": {
"type": "computed",
"value": "(!usePOSTGRE)"
"value": "(!postgre)"
},
"usePOSTGRE": {
"postgre": {
"type": "parameter",
"datatype": "bool",
"defaultValue": "false"
Expand Down
16 changes: 16 additions & 0 deletions src/Database/DatabaseProject/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<Project>
<Import Project="$([MSBuild]::GetPathOfFileAbove('Directory.Build.props', '$(MSBuildThisFileDirectory)../'))"/>
<ItemGroup>
<Using Include="placeHolder.Database.Entities" />
<Using Include="Microsoft.EntityFrameworkCore" />
<Using Include="Microsoft.EntityFrameworkCore.Metadata.Builders" />
<Using Include="Threenine" />
<!--#if (mssql) -->
<Using Include="Threenine.Configurations.SqlServer"/>
<!--#endif -->
<!--#if (postgre)-->
<Using Include="Threenine.Configurations.PostgreSql" />
<!--#endif -->
</ItemGroup>

</Project>
Empty file.
4 changes: 2 additions & 2 deletions src/Database/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.1"/>
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.1"/>
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="8.0.1"/>
<!--#if (useMSSQL) -->
<!--#if (mssql) -->
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.1"/>
<!--#endif -->
<!--#if (usePOSTGRE)-->
<!--#if (postgre)-->
<PackageReference Include="Npgsql" Version="8.0.1" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="8.0.0" />
<!--#endif -->
Expand Down
7 changes: 1 addition & 6 deletions src/ModelConfiguration/ModelConfiguration.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using Threenine;
#if(useMSSQL)
using Threenine.Configurations.SqlServer;
#endif
#if (usePOSTGRE)
using Threenine.Configurations.PostgreSql;
#endif


namespace placeHolder.Database.Configurations;

Expand Down
6 changes: 3 additions & 3 deletions src/Solution/.template.config/template.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@
"dataType": "string",
"defaultValue": "Threenine"
},
"useMSSQL": {
"mssql": {
"type": "computed",
"value": "(!usePOSTGRE)"
"value": "(!postgre)"
},
"usePOSTGRE": {
"postgre": {
"type": "parameter",
"datatype": "bool",
"defaultValue": "false"
Expand Down
23 changes: 0 additions & 23 deletions src/Solution/src/Api/Api.csproj
Original file line number Diff line number Diff line change
@@ -1,27 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<ItemGroup>
<PackageReference Include="Ardalis.ApiEndpoints" Version="4.1.0" />
<PackageReference Include="AutoMapper" Version="12.0.1" />
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="12.0.1" />
<PackageReference Include="Microsoft.AspNetCore.JsonPatch" Version="8.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="8.0.1" />
<PackageReference Include="FluentValidation" Version="11.9.0" />
<PackageReference Include="FluentValidation.AspNetCore" Version="11.3.0" />
<PackageReference Include="FluentValidation.DependencyInjectionExtensions" Version="11.9.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.1"/>
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.1" />
<PackageReference Include="Serilog.Exceptions" Version="8.4.0" />
<PackageReference Include="Serilog.Settings.Configuration" Version="8.0.0" />
<PackageReference Include="Serilog.Sinks.Seq" Version="6.0.0" />
<PackageReference Include="Threenine.DataService" Version="0.2.1" />
<PackageReference Include="MediatR" Version="12.2.0" />
<PackageReference Include="Serilog" Version="3.1.1" />
<PackageReference Include="Serilog.AspNetCore" Version="8.0.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" />
<PackageReference Include="Swashbuckle.AspNetCore.Annotations" Version="6.5.0" />
<PackageReference Include="Threenine.ApiResponse" Version="1.0.28" />
<PackageReference Include="Threenine.Data" Version="5.0.1" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Common\Common.csproj" />
<ProjectReference Include="..\Database\Database\Database.csproj" />
Expand Down
27 changes: 27 additions & 0 deletions src/Solution/src/Api/Directory.Packages.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<Project>
<PropertyGroup>
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Ardalis.ApiEndpoints" Version="4.1.0" />
<PackageReference Include="AutoMapper" Version="12.0.1" />
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="12.0.1" />
<PackageReference Include="Microsoft.AspNetCore.JsonPatch" Version="8.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="8.0.1" />
<PackageReference Include="FluentValidation" Version="11.9.0" />
<PackageReference Include="FluentValidation.AspNetCore" Version="11.3.0" />
<PackageReference Include="FluentValidation.DependencyInjectionExtensions" Version="11.9.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.1"/>
<PackageReference Include="Serilog.Exceptions" Version="8.4.0" />
<PackageReference Include="Serilog.Settings.Configuration" Version="8.0.0" />
<PackageReference Include="Serilog.Sinks.Seq" Version="6.0.0" />
<PackageReference Include="Threenine.DataService" Version="0.2.1" />
<PackageReference Include="MediatR" Version="12.2.0" />
<PackageReference Include="Serilog" Version="3.1.1" />
<PackageReference Include="Serilog.AspNetCore" Version="8.0.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" />
<PackageReference Include="Swashbuckle.AspNetCore.Annotations" Version="6.5.0" />
<PackageReference Include="Threenine.ApiResponse" Version="1.0.28" />
<PackageReference Include="Threenine.Data" Version="5.0.1" />
</ItemGroup>
</Project>

0 comments on commit 93384aa

Please sign in to comment.