Migration to net 6 - not working for now

This commit is contained in:
Roland Fieger
2021-10-14 16:53:06 +02:00
parent e9d30aad16
commit f8c6316d4e
13 changed files with 167 additions and 103 deletions

View File

@@ -27,7 +27,7 @@ namespace BusinessLogic.LookupLogic
public async Task<DataResult<List<LookupCategory>>> GetAllLookups() public async Task<DataResult<List<LookupCategory>>> GetAllLookups()
{ {
var result = await _lookupRepo.GetAllLookups(); var result = await _lookupRepo.GetAllLookups();
_logger.LogInformation($"Call to GetAllLookups ended with {nameof(result.GeneralResult)}"); _logger.LogInformation($"Call to GetAllLookups ended with {result.GeneralResult.ToString()}");
return result; return result;
} }

View File

@@ -1,17 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.Extensions.Configuration" Version="3.1.16" /> <PackageReference Include="Microsoft.Extensions.Configuration" Version="6.0.0-rc.2.21480.5"/>
<PackageReference Include="Microsoft.Extensions.Logging" Version="3.1.16" /> <PackageReference Include="Microsoft.Extensions.Logging" Version="6.0.0-rc.2.21480.5"/>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\..\Datamodels\Datamodels.csproj" /> <ProjectReference Include="..\..\Datamodels\Datamodels.csproj"/>
<ProjectReference Include="..\..\Repositories\Repositories.csproj" /> <ProjectReference Include="..\..\Repositories\Repositories.csproj"/>
</ItemGroup> </ItemGroup>
<PropertyGroup> <PropertyGroup>
<TargetFramework>netstandard2.1</TargetFramework> <TargetFramework>net6.0</TargetFramework>
</PropertyGroup> </PropertyGroup>
</Project> </Project>

View File

@@ -0,0 +1,9 @@
using System;
namespace SearchApi.Exceptions
{
public class FieldAliasMissingException : Exception
{
public FieldAliasMissingException(string message) : base(message: message) {}
}
}

View File

@@ -0,0 +1,9 @@
using System;
namespace SearchApi.Exceptions
{
public class TableAliasMissingException : Exception
{
public TableAliasMissingException(string message) : base(message: message) {}
}
}

View File

@@ -6,7 +6,7 @@ using Datamodels.BusinessModels;
using Datamodels.DatabaseModels; using Datamodels.DatabaseModels;
using Datamodels.SearchModels; using Datamodels.SearchModels;
namespace SearchLogic namespace SearchApi.SearchLogic
{ {
public interface ISearchLogic public interface ISearchLogic
{ {

View File

@@ -9,14 +9,21 @@ using Datamodels.SearchModels;
using Newtonsoft.Json; using Newtonsoft.Json;
using System.Linq; using System.Linq;
using System.Linq.Expressions; using System.Linq.Expressions;
using SearchApi.Exceptions;
namespace SearchLogic namespace SearchApi.SearchLogic
{ {
public class SearchLogic : ISearchLogic public class SearchLogic : ISearchLogic
{ {
private readonly ILogger<SearchLogic> _logger; private readonly ILogger<SearchLogic> _logger;
private readonly IFwMariaSearchRepo _searchRepo; private readonly IFwMariaSearchRepo _searchRepo;
private List<string> _tableNames;
private List<string> _joinConditions;
private List<string> _fieldNames;
private List<string> _whereConditions;
private List<string> _sortFields;
public SearchLogic(ILogger<SearchLogic> logger, IFwMariaSearchRepo searchRepo) public SearchLogic(ILogger<SearchLogic> logger, IFwMariaSearchRepo searchRepo)
{ {
_logger = logger; _logger = logger;
@@ -37,5 +44,61 @@ namespace SearchLogic
return result; return result;
} }
// Extract Table
private void GetTables(FilterModel filter)
{
bool hasTableList = filter.TableDescriptions.Count > 0;
_tableNames = new List<string>();
foreach(var table in filter.TableDescriptions)
{
if (hasTableList && string.IsNullOrEmpty(table.TableAlias))
{
throw new TableAliasMissingException($"No Alias defined for Table {table.TableName}");
}
_tableNames.Add($"{table.TableName} {(string.IsNullOrEmpty(table.TableAlias) ? string.Empty : table.TableAlias)}");
}
}
// Extract Fieldlist
private void GetFields(FilterModel filter)
{
var tables = filter.TableDescriptions;
foreach (var table in tables)
{
bool hasMultipleFields = table.Fields.Count > 0;
foreach (var field in table.Fields) {
if (hasMultipleFields && string.IsNullOrEmpty(field.FieldAlias))
{
throw new FieldAliasMissingException($"No Alias defined for Field {field.FieldName} in Table {table.TableName}");
}
_fieldNames.Add($"{table.TableAlias}.{field.FieldName} {field.FieldAlias}");
}
}
}
// Extract Join Path if more than one table
private void GetTableJoinConditions(FilterModel filter)
{
}
// Extract Where Conditions
private void GetWhereConditions(FilterModel filter)
{
}
// Extract Sort Items
private void GetSortFields(FilterModel filter)
{
}
// Assemble SQL Query
private string AssembleSqlQuery()
{
return null;
}
} }
} }

View File

@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFramework>netstandard2.1</TargetFramework> <TargetFramework>net6.0</TargetFramework>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>

View File

@@ -1,22 +1,18 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\Datamodels\Datamodels.csproj" /> <ProjectReference Include="..\Datamodels\Datamodels.csproj"/>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="3.1.16" /> <PackageReference Include="Microsoft.EntityFrameworkCore" Version="6.0.0-rc.2.21480.5"/>
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="3.1.16"> <PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="6.0.0-rc.2.21480.5">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
</PackageReference> </PackageReference>
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="3.2.6" /> <PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="6.0.0-preview.7"/>
<PackageReference Include="Microsoft.Extensions.Configuration" Version="3.1.16" /> <PackageReference Include="Microsoft.Extensions.Configuration" Version="6.0.0-rc.2.21480.5"/>
<PackageReference Include="Microsoft.Extensions.Logging" Version="3.1.16" /> <PackageReference Include="Microsoft.Extensions.Logging" Version="6.0.0-rc.2.21480.5"/>
</ItemGroup> </ItemGroup>
<PropertyGroup> <PropertyGroup>
<TargetFramework>netstandard2.1</TargetFramework> <TargetFramework>net6.0</TargetFramework>
</PropertyGroup> </PropertyGroup>
</Project> </Project>

View File

@@ -2,7 +2,7 @@ using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using System.Threading.Tasks; using System.Threading.Tasks;
using SearchLogic; using SearchApi.SearchLogic;
using Datamodels.SearchModels; using Datamodels.SearchModels;
using System.Collections.Generic; using System.Collections.Generic;
using Datamodels.DatabaseModels; using Datamodels.DatabaseModels;

View File

@@ -1,41 +1,36 @@
<Project Sdk="Microsoft.NET.Sdk.Web"> <Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup> <PropertyGroup>
<TargetFramework>net6.0</TargetFramework> <TargetFramework>net6.0</TargetFramework>
<LangVersion>10</LangVersion> <LangVersion>10</LangVersion>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Elastic.Apm.EntityFrameworkCore" Version="1.11.1" /> <PackageReference Include="Elastic.Apm.EntityFrameworkCore" Version="1.11.1"/>
<PackageReference Include="Elastic.Apm.NetCoreAll" Version="1.11.1" /> <PackageReference Include="Elastic.Apm.NetCoreAll" Version="1.11.1"/>
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="3.1.16" /> <PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="6.0.0-rc.2.21480.10"/>
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" /> <PackageReference Include="Newtonsoft.Json" Version="13.0.1"/>
<PackageReference Include="OpenTelemetry.Contrib.Instrumentation.EntityFrameworkCore" Version="1.0.0-beta2" /> <PackageReference Include="OpenTelemetry.Contrib.Instrumentation.EntityFrameworkCore" Version="1.0.0-beta2"/>
<PackageReference Include="OpenTelemetry.Exporter.Console" Version="1.1.0" /> <PackageReference Include="OpenTelemetry.Exporter.Console" Version="1.1.0"/>
<PackageReference Include="OpenTelemetry.Exporter.OpenTelemetryProtocol" Version="1.1.0" /> <PackageReference Include="OpenTelemetry.Exporter.OpenTelemetryProtocol" Version="1.1.0"/>
<PackageReference Include="OpenTelemetry.Extensions.Hosting" Version="1.0.0-rc7" /> <PackageReference Include="OpenTelemetry.Extensions.Hosting" Version="1.0.0-rc7"/>
<PackageReference Include="OpenTelemetry.Instrumentation.AspNetCore" Version="1.0.0-rc7" /> <PackageReference Include="OpenTelemetry.Instrumentation.AspNetCore" Version="1.0.0-rc7"/>
<PackageReference Include="OpenTelemetry.Instrumentation.Http" Version="1.0.0-rc7" /> <PackageReference Include="OpenTelemetry.Instrumentation.Http" Version="1.0.0-rc7"/>
<PackageReference Include="Serilog.AspNetCore" Version="4.1.0" /> <PackageReference Include="Serilog.AspNetCore" Version="4.1.0"/>
<PackageReference Include="Serilog.Enrichers.Environment" Version="2.2.0" /> <PackageReference Include="Serilog.Enrichers.Environment" Version="2.2.0"/>
<PackageReference Include="Serilog.Enrichers.ExceptionStackTraceHash" Version="1.3.0" /> <PackageReference Include="Serilog.Enrichers.ExceptionStackTraceHash" Version="1.3.0"/>
<PackageReference Include="Serilog.Exceptions" Version="7.1.0" /> <PackageReference Include="Serilog.Exceptions" Version="7.1.0"/>
<PackageReference Include="Serilog.Formatting.Elasticsearch" Version="8.4.1" /> <PackageReference Include="Serilog.Formatting.Elasticsearch" Version="8.4.1"/>
<PackageReference Include="Serilog.Settings.Configuration" Version="3.3.0" /> <PackageReference Include="Serilog.Settings.Configuration" Version="3.3.0"/>
<PackageReference Include="serilog.sinks.console" Version="4.0.0" /> <PackageReference Include="serilog.sinks.console" Version="4.0.0"/>
<PackageReference Include="Serilog.Sinks.ElasticSearch" Version="8.4.1" /> <PackageReference Include="Serilog.Sinks.ElasticSearch" Version="8.4.1"/>
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.2.2" /> <PackageReference Include="Swashbuckle.AspNetCore" Version="6.2.2"/>
<PackageReference Include="Swashbuckle.AspNetCore.Swagger" Version="6.2.2" /> <PackageReference Include="Swashbuckle.AspNetCore.Swagger" Version="6.2.2"/>
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerGen" Version="6.2.2" /> <PackageReference Include="Swashbuckle.AspNetCore.SwaggerGen" Version="6.2.2"/>
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerUI" Version="6.2.2" /> <PackageReference Include="Swashbuckle.AspNetCore.SwaggerUI" Version="6.2.2"/>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\BusinessLogic\LookupLogic\LookupLogic.csproj" /> <ProjectReference Include="..\BusinessLogic\LookupLogic\LookupLogic.csproj"/>
<ProjectReference Include="..\BusinessLogic\SearchLogic\SearchLogic.csproj" /> <ProjectReference Include="..\BusinessLogic\SearchLogic\SearchLogic.csproj"/>
<ProjectReference Include="..\Datamodels\Datamodels.csproj" /> <ProjectReference Include="..\Datamodels\Datamodels.csproj"/>
<ProjectReference Include="..\Repositories\Repositories.csproj" /> <ProjectReference Include="..\Repositories\Repositories.csproj"/>
</ItemGroup> </ItemGroup>
</Project> </Project>

View File

@@ -16,7 +16,7 @@ using OpenTelemetry.Trace;
using Repositories; using Repositories;
using Repositories.Interfaces; using Repositories.Interfaces;
using SearchLogic; using SearchApi.SearchLogic;
namespace FwSearchApi namespace FwSearchApi
{ {
@@ -43,7 +43,7 @@ namespace FwSearchApi
services.AddTransient<ILookupLogic, FwLookupLogic>(); services.AddTransient<ILookupLogic, FwLookupLogic>();
services.AddTransient<IFwMariaLookupRepo, FwMariaLookupRepo>(); services.AddTransient<IFwMariaLookupRepo, FwMariaLookupRepo>();
services.AddTransient<IFwMariaSearchRepo, FwMariaSearchRepo>(); services.AddTransient<IFwMariaSearchRepo, FwMariaSearchRepo>();
services.AddTransient<ISearchLogic, SearchLogic.SearchLogic>(); services.AddTransient<ISearchLogic, SearchLogic>();
services.AddSwaggerGen(); services.AddSwaggerGen();
AppContext.SetSwitch("System.Net.Http.SocketsHttpHandler.Http2UnencryptedSupport", true); //needed if no Security is used when calling APM Server AppContext.SetSwitch("System.Net.Http.SocketsHttpHandler.Http2UnencryptedSupport", true); //needed if no Security is used when calling APM Server
services.AddOpenTelemetryTracing((builder) => builder services.AddOpenTelemetryTracing((builder) => builder

View File

@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework> <TargetFramework>net6.0</TargetFramework>
<IsPackable>false</IsPackable> <IsPackable>false</IsPackable>
</PropertyGroup> </PropertyGroup>

View File

@@ -1,19 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\..\..\Repositories\Repositories.csproj" /> <ProjectReference Include="..\..\..\Repositories\Repositories.csproj"/>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="3.1.16"> <PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="6.0.0-rc.2.21480.5">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
</PackageReference> </PackageReference>
</ItemGroup> </ItemGroup>
<PropertyGroup> <PropertyGroup>
<OutputType>Exe</OutputType> <OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework> <TargetFramework>net6.0</TargetFramework>
</PropertyGroup> </PropertyGroup>
</Project> </Project>