will think about it again better.
This commit is contained in:
parent
bddf4eec25
commit
8175dc5f3d
@ -1,10 +0,0 @@
|
|||||||
using PoweredSoft.DynamicQuery.Core;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
|
|
||||||
namespace PoweredSoft.AdvanceQuery.Abstractions
|
|
||||||
{
|
|
||||||
public interface IAggregatableQuery
|
|
||||||
{
|
|
||||||
List<IAggregate> GetAggregates();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,12 +0,0 @@
|
|||||||
using PoweredSoft.DynamicQuery.Core;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Text;
|
|
||||||
|
|
||||||
namespace PoweredSoft.AdvanceQuery.Abstractions
|
|
||||||
{
|
|
||||||
public interface IFilterableQuery
|
|
||||||
{
|
|
||||||
List<IFilter> GetFilters();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,10 +0,0 @@
|
|||||||
using PoweredSoft.DynamicQuery.Core;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
|
|
||||||
namespace PoweredSoft.AdvanceQuery.Abstractions
|
|
||||||
{
|
|
||||||
public interface IGroupableQuery
|
|
||||||
{
|
|
||||||
List<IGroup> GetGroups();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,11 +0,0 @@
|
|||||||
using System;
|
|
||||||
|
|
||||||
namespace PoweredSoft.AdvanceQuery.Abstractions
|
|
||||||
{
|
|
||||||
|
|
||||||
public interface IPageableQuery
|
|
||||||
{
|
|
||||||
int? GetPage();
|
|
||||||
int? GetPageSize();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,10 +0,0 @@
|
|||||||
using PoweredSoft.DynamicQuery.Core;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
|
|
||||||
namespace PoweredSoft.AdvanceQuery.Abstractions
|
|
||||||
{
|
|
||||||
public interface ISortableQuery
|
|
||||||
{
|
|
||||||
List<ISort> GetSorts();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,11 +0,0 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
|
||||||
|
|
||||||
<PropertyGroup>
|
|
||||||
<TargetFramework>netstandard2.0</TargetFramework>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<PackageReference Include="PoweredSoft.DynamicQuery.Core" Version="2.1.4" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
</Project>
|
|
@ -1,68 +0,0 @@
|
|||||||
using PoweredSoft.AdvanceQuery.Abstractions;
|
|
||||||
using PoweredSoft.DynamicQuery;
|
|
||||||
using PoweredSoft.DynamicQuery.Core;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Threading;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace PoweredSoft.CQRS.AdvanceQuery
|
|
||||||
{
|
|
||||||
public abstract class AdvanceQueryHandlerBase<TQuery, TSource, TDestination>
|
|
||||||
where TQuery : class
|
|
||||||
{
|
|
||||||
private readonly IQueryHandlerAsync queryHandlerAsync;
|
|
||||||
|
|
||||||
protected AdvanceQueryHandlerBase(IQueryHandlerAsync queryHandlerAsync)
|
|
||||||
{
|
|
||||||
this.queryHandlerAsync = queryHandlerAsync;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected async Task<IQueryExecutionResult<TDestination>> ProcessQuery(TQuery query, IQueryable<TSource> source,
|
|
||||||
CancellationToken cancellationToken = default)
|
|
||||||
{
|
|
||||||
var criteria = CreateCriteria(query);
|
|
||||||
var options = GetOptions(query);
|
|
||||||
var interceptors = GetInterceptors(query);
|
|
||||||
|
|
||||||
foreach (var interceptor in interceptors)
|
|
||||||
queryHandlerAsync.AddInterceptor(interceptor);
|
|
||||||
|
|
||||||
var result = await queryHandlerAsync.ExecuteAsync<TSource, TDestination>(source, criteria, options, cancellationToken);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected virtual IEnumerable<IQueryInterceptor> GetInterceptors(TQuery query)
|
|
||||||
{
|
|
||||||
return Enumerable.Empty<IQueryInterceptor>();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected virtual IQueryExecutionOptions GetOptions(TQuery query)
|
|
||||||
{
|
|
||||||
return new QueryExecutionOptions();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected virtual IQueryCriteria CreateCriteria(TQuery query)
|
|
||||||
{
|
|
||||||
var ret = new QueryCriteria();
|
|
||||||
|
|
||||||
if (query is IPageableQuery pageableQuery)
|
|
||||||
{
|
|
||||||
ret.Page = pageableQuery.GetPage();
|
|
||||||
ret.PageSize = pageableQuery.GetPageSize();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (query is IFilterableQuery filterableQuery)
|
|
||||||
ret.Filters = filterableQuery.GetFilters();
|
|
||||||
|
|
||||||
if (query is IGroupableQuery groupableQuery)
|
|
||||||
ret.Groups = groupableQuery.GetGroups();
|
|
||||||
|
|
||||||
if (query is IAggregatableQuery aggregatableQuery)
|
|
||||||
ret.Aggregates = aggregatableQuery.GetAggregates();
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,15 +0,0 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
|
||||||
|
|
||||||
<PropertyGroup>
|
|
||||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<PackageReference Include="PoweredSoft.DynamicQuery" Version="2.1.4" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<ProjectReference Include="..\PoweredSoft.AdvanceQuery.Abstractions\PoweredSoft.AdvanceQuery.Abstractions.csproj" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
</Project>
|
|
@ -19,10 +19,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
|
|||||||
README.md = README.md
|
README.md = README.md
|
||||||
EndProjectSection
|
EndProjectSection
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PoweredSoft.CQRS.AdvanceQuery", "PoweredSoft.CQRS.AdvanceQuery\PoweredSoft.CQRS.AdvanceQuery.csproj", "{7A6DCAD7-4C01-426A-86AB-2F9AC5F19FB5}"
|
|
||||||
EndProject
|
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PoweredSoft.AdvanceQuery.Abstractions", "PoweredSoft.AdvanceQuery.Abstractions\PoweredSoft.AdvanceQuery.Abstractions.csproj", "{FEE14DBC-7D3F-4805-8080-918CD5D52C7D}"
|
|
||||||
EndProject
|
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
Debug|Any CPU = Debug|Any CPU
|
||||||
@ -49,14 +45,6 @@ Global
|
|||||||
{F15B1E11-8D4C-489E-AFF7-AA144105FE46}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{F15B1E11-8D4C-489E-AFF7-AA144105FE46}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{F15B1E11-8D4C-489E-AFF7-AA144105FE46}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{F15B1E11-8D4C-489E-AFF7-AA144105FE46}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{F15B1E11-8D4C-489E-AFF7-AA144105FE46}.Release|Any CPU.Build.0 = Release|Any CPU
|
{F15B1E11-8D4C-489E-AFF7-AA144105FE46}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
{7A6DCAD7-4C01-426A-86AB-2F9AC5F19FB5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
|
||||||
{7A6DCAD7-4C01-426A-86AB-2F9AC5F19FB5}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
|
||||||
{7A6DCAD7-4C01-426A-86AB-2F9AC5F19FB5}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
|
||||||
{7A6DCAD7-4C01-426A-86AB-2F9AC5F19FB5}.Release|Any CPU.Build.0 = Release|Any CPU
|
|
||||||
{FEE14DBC-7D3F-4805-8080-918CD5D52C7D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
|
||||||
{FEE14DBC-7D3F-4805-8080-918CD5D52C7D}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
|
||||||
{FEE14DBC-7D3F-4805-8080-918CD5D52C7D}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
|
||||||
{FEE14DBC-7D3F-4805-8080-918CD5D52C7D}.Release|Any CPU.Build.0 = Release|Any CPU
|
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
Loading…
Reference in New Issue
Block a user