Skip to content

Commit

Permalink
filtering and sorting cast
Browse files Browse the repository at this point in the history
  • Loading branch information
Edgar Mesquita authored and Edgar Mesquita committed Aug 13, 2023
1 parent 03f7dc4 commit 3e40f4d
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 14 deletions.
6 changes: 3 additions & 3 deletions src/eQuantic.Core.Api.Crud/eQuantic.Core.Api.Crud.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
<Authors>eQuantic Systems</Authors>
<RootNamespace>eQuantic.Core.Api.Crud</RootNamespace>
<AssemblyTitle>eQuantic.Core.Api.Crud</AssemblyTitle>
<AssemblyVersion>1.0.10.0</AssemblyVersion>
<FileVersion>1.0.10.0</FileVersion>
<Version>1.0.10.0</Version>
<AssemblyVersion>1.0.11.0</AssemblyVersion>
<FileVersion>1.0.11.0</FileVersion>
<Version>1.0.11.0</Version>
<TargetFramework>net7.0</TargetFramework>

<PackageId>eQuantic.Core.Api.Crud</PackageId>
Expand Down
6 changes: 3 additions & 3 deletions src/eQuantic.Core.Api/eQuantic.Core.Api.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
<Authors>eQuantic Systems</Authors>
<RootNamespace>eQuantic.Core.Api</RootNamespace>
<AssemblyTitle>eQuantic.Core.Api</AssemblyTitle>
<AssemblyVersion>1.0.10.0</AssemblyVersion>
<FileVersion>1.0.10.0</FileVersion>
<Version>1.0.10.0</Version>
<AssemblyVersion>1.0.11.0</AssemblyVersion>
<FileVersion>1.0.11.0</FileVersion>
<Version>1.0.11.0</Version>
<TargetFramework>net7.0</TargetFramework>

<PackageId>eQuantic.Core.Api</PackageId>
Expand Down
28 changes: 26 additions & 2 deletions src/eQuantic.Core.Application.Crud/Services/ReaderServiceBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -57,12 +60,20 @@ protected ReaderServiceBase(IDefaultUnitOfWork unitOfWork, IMapperFactory mapper
CancellationToken cancellationToken = default)
{
var filtering = request.Filtering
.Cast<TDataEntity>(opt => opt.ExcludeUnmapped()).ToList();
.Cast<TDataEntity>(opt =>
{
OnCastEntity(opt);
OnCastFiltering(opt);
}).ToList();

SetReferenceFiltering(request, filtering);

var sorting = request.Sorting
.Cast<TDataEntity>(opt => opt.ExcludeUnmapped());
.Cast<TDataEntity>(opt =>
{
OnCastEntity(opt);
OnCastSorting(opt);
});

Specification<TDataEntity> specification = filtering.Any()
? new EntityFilterSpecification<TDataEntity>(filtering.ToArray())
Expand Down Expand Up @@ -93,6 +104,19 @@ protected virtual string[] OnGetProperties()
return Array.Empty<string>();
}

protected virtual void OnCastEntity<TCastOptions>(TCastOptions options)
where TCastOptions : ICastOptions<TCastOptions, TDataEntity>
{
}

protected virtual void OnCastFiltering(FilteringCastOptions<TDataEntity> options)
{
}

protected virtual void OnCastSorting(SortingCastOptions<TDataEntity> options)
{
}

protected virtual TEntity? OnMapEntity(TDataEntity dataEntity)
{
var mapper = MapperFactory.GetMapper<TDataEntity, TEntity>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
<Authors>eQuantic Systems</Authors>
<RootNamespace>eQuantic.Core.Application.Crud</RootNamespace>
<AssemblyTitle>eQuantic.Core.Application.Crud</AssemblyTitle>
<AssemblyVersion>1.0.10.0</AssemblyVersion>
<FileVersion>1.0.10.0</FileVersion>
<Version>1.0.10.0</Version>
<AssemblyVersion>1.0.11.0</AssemblyVersion>
<FileVersion>1.0.11.0</FileVersion>
<Version>1.0.11.0</Version>
<TargetFrameworks>netstandard2.1;net7.0</TargetFrameworks>

<PackageId>eQuantic.Core.Application.Crud</PackageId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
<Authors>eQuantic Systems</Authors>
<RootNamespace>eQuantic.Core.Application</RootNamespace>
<AssemblyTitle>eQuantic.Core.Application</AssemblyTitle>
<AssemblyVersion>1.0.10.0</AssemblyVersion>
<FileVersion>1.0.10.0</FileVersion>
<Version>1.0.10.0</Version>
<AssemblyVersion>1.0.11.0</AssemblyVersion>
<FileVersion>1.0.11.0</FileVersion>
<Version>1.0.11.0</Version>
<TargetFrameworks>netstandard2.1;net7.0</TargetFrameworks>

<PackageId>eQuantic.Core.Application</PackageId>
Expand Down

0 comments on commit 3e40f4d

Please sign in to comment.