From 3e40f4dc8778add9b59223b2dfcf92595a66dde8 Mon Sep 17 00:00:00 2001 From: Edgar Mesquita Date: Sun, 13 Aug 2023 15:43:22 +0100 Subject: [PATCH] filtering and sorting cast --- .../eQuantic.Core.Api.Crud.csproj | 6 ++-- .../eQuantic.Core.Api.csproj | 6 ++-- .../Services/ReaderServiceBase.cs | 28 +++++++++++++++++-- .../eQuantic.Core.Application.Crud.csproj | 6 ++-- .../eQuantic.Core.Application.csproj | 6 ++-- 5 files changed, 38 insertions(+), 14 deletions(-) diff --git a/src/eQuantic.Core.Api.Crud/eQuantic.Core.Api.Crud.csproj b/src/eQuantic.Core.Api.Crud/eQuantic.Core.Api.Crud.csproj index 0c8935e..6b31b14 100644 --- a/src/eQuantic.Core.Api.Crud/eQuantic.Core.Api.Crud.csproj +++ b/src/eQuantic.Core.Api.Crud/eQuantic.Core.Api.Crud.csproj @@ -6,9 +6,9 @@ eQuantic Systems eQuantic.Core.Api.Crud eQuantic.Core.Api.Crud - 1.0.10.0 - 1.0.10.0 - 1.0.10.0 + 1.0.11.0 + 1.0.11.0 + 1.0.11.0 net7.0 eQuantic.Core.Api.Crud diff --git a/src/eQuantic.Core.Api/eQuantic.Core.Api.csproj b/src/eQuantic.Core.Api/eQuantic.Core.Api.csproj index 938302d..cca8a72 100644 --- a/src/eQuantic.Core.Api/eQuantic.Core.Api.csproj +++ b/src/eQuantic.Core.Api/eQuantic.Core.Api.csproj @@ -6,9 +6,9 @@ eQuantic Systems eQuantic.Core.Api eQuantic.Core.Api - 1.0.10.0 - 1.0.10.0 - 1.0.10.0 + 1.0.11.0 + 1.0.11.0 + 1.0.11.0 net7.0 eQuantic.Core.Api diff --git a/src/eQuantic.Core.Application.Crud/Services/ReaderServiceBase.cs b/src/eQuantic.Core.Application.Crud/Services/ReaderServiceBase.cs index a88ba9b..a8bcead 100644 --- a/src/eQuantic.Core.Application.Crud/Services/ReaderServiceBase.cs +++ b/src/eQuantic.Core.Application.Crud/Services/ReaderServiceBase.cs @@ -4,8 +4,11 @@ using eQuantic.Core.Collections; using eQuantic.Core.Data.Repository; using eQuantic.Core.Data.Repository.Sql; +using eQuantic.Linq.Casting; using eQuantic.Linq.Filter; +using eQuantic.Linq.Filter.Casting; using eQuantic.Linq.Filter.Extensions; +using eQuantic.Linq.Sorter.Casting; using eQuantic.Linq.Sorter.Extensions; using eQuantic.Linq.Specification; using eQuantic.Mapper; @@ -57,12 +60,20 @@ protected ReaderServiceBase(IDefaultUnitOfWork unitOfWork, IMapperFactory mapper CancellationToken cancellationToken = default) { var filtering = request.Filtering - .Cast(opt => opt.ExcludeUnmapped()).ToList(); + .Cast(opt => + { + OnCastEntity(opt); + OnCastFiltering(opt); + }).ToList(); SetReferenceFiltering(request, filtering); var sorting = request.Sorting - .Cast(opt => opt.ExcludeUnmapped()); + .Cast(opt => + { + OnCastEntity(opt); + OnCastSorting(opt); + }); Specification specification = filtering.Any() ? new EntityFilterSpecification(filtering.ToArray()) @@ -93,6 +104,19 @@ protected virtual string[] OnGetProperties() return Array.Empty(); } + protected virtual void OnCastEntity(TCastOptions options) + where TCastOptions : ICastOptions + { + } + + protected virtual void OnCastFiltering(FilteringCastOptions options) + { + } + + protected virtual void OnCastSorting(SortingCastOptions options) + { + } + protected virtual TEntity? OnMapEntity(TDataEntity dataEntity) { var mapper = MapperFactory.GetMapper(); diff --git a/src/eQuantic.Core.Application.Crud/eQuantic.Core.Application.Crud.csproj b/src/eQuantic.Core.Application.Crud/eQuantic.Core.Application.Crud.csproj index dedc2bb..764ae60 100644 --- a/src/eQuantic.Core.Application.Crud/eQuantic.Core.Application.Crud.csproj +++ b/src/eQuantic.Core.Application.Crud/eQuantic.Core.Application.Crud.csproj @@ -6,9 +6,9 @@ eQuantic Systems eQuantic.Core.Application.Crud eQuantic.Core.Application.Crud - 1.0.10.0 - 1.0.10.0 - 1.0.10.0 + 1.0.11.0 + 1.0.11.0 + 1.0.11.0 netstandard2.1;net7.0 eQuantic.Core.Application.Crud diff --git a/src/eQuantic.Core.Application/eQuantic.Core.Application.csproj b/src/eQuantic.Core.Application/eQuantic.Core.Application.csproj index 7e302bc..7073732 100644 --- a/src/eQuantic.Core.Application/eQuantic.Core.Application.csproj +++ b/src/eQuantic.Core.Application/eQuantic.Core.Application.csproj @@ -6,9 +6,9 @@ eQuantic Systems eQuantic.Core.Application eQuantic.Core.Application - 1.0.10.0 - 1.0.10.0 - 1.0.10.0 + 1.0.11.0 + 1.0.11.0 + 1.0.11.0 netstandard2.1;net7.0 eQuantic.Core.Application