query result
This commit is contained in:
parent
dd65a46b4b
commit
f5034779ae
@ -3,14 +3,20 @@ Microsoft Visual Studio Solution File, Format Version 12.00
|
|||||||
# Visual Studio 15
|
# Visual Studio 15
|
||||||
VisualStudioVersion = 15.0.28010.0
|
VisualStudioVersion = 15.0.28010.0
|
||||||
MinimumVisualStudioVersion = 10.0.40219.1
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PoweredSoft.DynamicQuery.Core", "PoweredSoft.DynamicQuery.Core\PoweredSoft.DynamicQuery.Core.csproj", "{E614658D-6852-4405-B5BE-3695C3E96B13}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PoweredSoft.DynamicQuery.Core", "PoweredSoft.DynamicQuery.Core\PoweredSoft.DynamicQuery.Core.csproj", "{E614658D-6852-4405-B5BE-3695C3E96B13}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PoweredSoft.DynamicQuery", "PoweredSoft.DynamicQuery\PoweredSoft.DynamicQuery.csproj", "{A9F74387-6B09-423A-96BC-F8FF345193EE}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PoweredSoft.DynamicQuery", "PoweredSoft.DynamicQuery\PoweredSoft.DynamicQuery.csproj", "{A9F74387-6B09-423A-96BC-F8FF345193EE}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PoweredSoft.DynamicQuery.Cli", "PoweredSoft.DynamicQuery.Cli\PoweredSoft.DynamicQuery.Cli.csproj", "{7FC0F790-A8B9-4335-8D72-09797DEB0359}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PoweredSoft.DynamicQuery.Cli", "PoweredSoft.DynamicQuery.Cli\PoweredSoft.DynamicQuery.Cli.csproj", "{7FC0F790-A8B9-4335-8D72-09797DEB0359}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PoweredSoft.DynamicLinq", "..\DynamicLinq\PoweredSoft.DynamicLinq\PoweredSoft.DynamicLinq.csproj", "{E4E954E0-66FA-4D72-979A-FB2EF8356A90}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PoweredSoft.DynamicLinq", "..\DynamicLinq\PoweredSoft.DynamicLinq\PoweredSoft.DynamicLinq.csproj", "{E4E954E0-66FA-4D72-979A-FB2EF8356A90}"
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{BD742C81-D26A-466C-AB9B-840996D59FA6}"
|
||||||
|
ProjectSection(SolutionItems) = preProject
|
||||||
|
LICENSE.md = LICENSE.md
|
||||||
|
README.md = README.md
|
||||||
|
EndProjectSection
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
Debug|Any CPU = Debug|Any CPU
|
||||||
|
@ -113,6 +113,8 @@ namespace PoweredSoft.DynamicQuery.Cli
|
|||||||
//, new Group { Path = "Sexe" }
|
//, new Group { Path = "Sexe" }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
criteria.Aggregates = new List<IAggregate>()
|
criteria.Aggregates = new List<IAggregate>()
|
||||||
{
|
{
|
||||||
new Aggregate { Type = AggregateType.Count },
|
new Aggregate { Type = AggregateType.Count },
|
||||||
|
107
README.md
Normal file
107
README.md
Normal file
@ -0,0 +1,107 @@
|
|||||||
|
# Dynamic Query
|
||||||
|
|
||||||
|
It's a library that allows you to easily query a queryable using a criteria object.
|
||||||
|
|
||||||
|
It allows offers, to intercept the query using **IQueryInterceptor** implementations.
|
||||||
|
|
||||||
|
## Getting Started
|
||||||
|
|
||||||
|
> Install nuget package to your awesome project.
|
||||||
|
|
||||||
|
Full Version | NuGet | NuGet Install
|
||||||
|
------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------:
|
||||||
|
PoweredSoft.DynamicQuery | <a href="https://www.nuget.org/packages/PoweredSoft.DynamicQuery/" target="_blank">[![NuGet](https://img.shields.io/nuget/v/PoweredSoft.DynamicQuery.svg?style=flat-square&label=nuget)](https://www.nuget.org/packages/PoweredSoft.DynamicQuery/)</a> | ```PM> Install-Package PoweredSoft.DynamicQuery```
|
||||||
|
PoweredSoft.DynamicQuery.Core | <a href="https://www.nuget.org/packages/PoweredSoft.DynamicQuery.Core/" target="_blank">[![NuGet](https://img.shields.io/nuget/v/PoweredSoft.DynamicQuery.Core.svg?style=flat-square&label=nuget)](https://www.nuget.org/packages/PoweredSoft.DynamicQuery.Core/)</a> | ```PM> Install-Package PoweredSoft.DynamicQuery.Core```
|
||||||
|
|
||||||
|
## Criteria
|
||||||
|
|
||||||
|
Criteria must implement the following interfaces
|
||||||
|
|
||||||
|
Object | Interface | Implementation | Example | Description
|
||||||
|
---------------|-----------------------------------------------------------------------------|-----------------------------------------------------------------------------------|-------------------------------------------------------------|---------------------------------------
|
||||||
|
Query Criteria | [interface](../blob/master/PoweredSoft.DynamicQuery.Core/IQueryCriteria.cs) | [default implemetation](../blob/master/PoweredSoft.DynamicQuery.QueryCriteria.cs) | [test](../blob/master/PoweredSoft.DynamicQuery.Test/TBT.md) | Wraps the query parameters
|
||||||
|
Filter | [interface](../blob/master/PoweredSoft.DynamicQuery.Core/IFilter.cs) | [default implemetation](../blob/master/PoweredSoft.DynamicQuery.Filter.cs) | [test](../blob/master/PoweredSoft.DynamicQuery.Test/TBT.md) | Represent a filter to be executed
|
||||||
|
Sort | [interface](../blob/master/PoweredSoft.DynamicQuery.Core/ISort.cs) | [default implemetation](../blob/master/PoweredSoft.DynamicQuery.Sort.cs) | [test](../blob/master/PoweredSoft.DynamicQuery.Test/TBT.md) | Represent a sort to be executed
|
||||||
|
Group | [interface](../blob/master/PoweredSoft.DynamicQuery.Core/IGroup.cs) | [default implemetation](../blob/master/PoweredSoft.DynamicQuery.Group.cs) | [test](../blob/master/PoweredSoft.DynamicQuery.Test/TBT.md) | Represent a group to be executed
|
||||||
|
Aggregate | [interface](../blob/master/PoweredSoft.DynamicQuery.Core/IAggregate.cs) | [default implemetation](../blob/master/PoweredSoft.DynamicQuery.Aggregate.cs) | [test](../blob/master/PoweredSoft.DynamicQuery.Test/TBT.md) | Represent an aggregate to be executed
|
||||||
|
|
||||||
|
### Sample
|
||||||
|
|
||||||
|
```csharp
|
||||||
|
var criteria = new QueryCriteria
|
||||||
|
{
|
||||||
|
Page = 1,
|
||||||
|
PageSize = 12,
|
||||||
|
Filters = new List<IFilter>
|
||||||
|
{
|
||||||
|
new SimpleFilter { Path = "FirstName", Type = FilterType.Equal, Value = "John" }
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
var queryHandler = new QueryHandler();
|
||||||
|
IQueryExecutionResult result = queryHandler.Execute(someQueryable, criteria);
|
||||||
|
```
|
||||||
|
|
||||||
|
## Query Result
|
||||||
|
|
||||||
|
Here is the interfaces that represent the result of query handling execution.
|
||||||
|
|
||||||
|
```csharp
|
||||||
|
public interface IAggregateResult
|
||||||
|
{
|
||||||
|
string Path { get; set; }
|
||||||
|
AggregateType Type { get; set; }
|
||||||
|
object Value { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public interface IQueryResult
|
||||||
|
{
|
||||||
|
List<IAggregateResult> Aggregates { get; }
|
||||||
|
List<object> Data { get; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public interface IGroupQueryResult : IQueryResult
|
||||||
|
{
|
||||||
|
string GroupPath { get; set; }
|
||||||
|
object GroupValue { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public interface IQueryExecutionResult : IQueryResult
|
||||||
|
{
|
||||||
|
long TotalRecords { get; set; }
|
||||||
|
long? NumberOfPages { get; set; }
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
## Interceptors
|
||||||
|
|
||||||
|
Interceptors are meant to add hooks at certain part of the query handling to allow alteration of the criterias or the queryable it self.\
|
||||||
|
The following is documented in the order of what they are called by the **default** query handler implementation.
|
||||||
|
|
||||||
|
> Before the expression is being built
|
||||||
|
|
||||||
|
Interceptor | Interface | Example | Description
|
||||||
|
---------------------------------------|--------------------------------------------------------------------------------------------|-------------------------------------------------------------|------------------------------------------------------------------------------------------------------------
|
||||||
|
IIncludeStrategyInterceptor | [interface](../blob/master/PoweredSoft.DynamicQuery.Core/IIncludeStrategyInterceptor.cs) | [test](../blob/master/PoweredSoft.DynamicQuery.Test/TBT.md) | This is to allow you to specify include paths for the queryable
|
||||||
|
IIncludeStrategyInterceptor<T> | [interface](../blob/master/PoweredSoft.DynamicQuery.Core/IIncludeStrategyInterceptor.cs) | [test](../blob/master/PoweredSoft.DynamicQuery.Test/TBT.md) | This is to allow you to specify include paths for the queryable
|
||||||
|
IBeforeQueryFilterInterceptor | [interface](../blob/master/PoweredSoft.DynamicQuery.Core/IBeforeQueryFilterInterceptor.cs) | [test](../blob/master/PoweredSoft.DynamicQuery.Test/TBT.md) | Before adding the filters to the expression
|
||||||
|
IBeforeQueryFilterInterceptor<T> | [interface](../blob/master/PoweredSoft.DynamicQuery.Core/IBeforeQueryFilterInterceptor.cs) | [test](../blob/master/PoweredSoft.DynamicQuery.Test/TBT.md) | Before adding the filters to the expression
|
||||||
|
INoSortInterceptor | [interface](../blob/master/PoweredSoft.DynamicQuery.Core/INoSortInterceptor.cs) | [test](../blob/master/PoweredSoft.DynamicQuery.Test/TBT.md) | This is called to allow you to specify an OrderBy in case none is specified, to avoid paging crash with EF6
|
||||||
|
INoSortInterceptor<T> | [interface](../blob/master/PoweredSoft.DynamicQuery.Core/INoSortInterceptor.cs) | [test](../blob/master/PoweredSoft.DynamicQuery.Test/TBT.md) | This is called to allow you to specify an OrderBy in case none is specified, to avoid paging crash with EF6
|
||||||
|
|
||||||
|
> After/During expression building before query execution
|
||||||
|
|
||||||
|
Interceptor | Interface | Example | Description
|
||||||
|
----------------------|------------------------------------------------------------------------------------|-------------------------------------------------------------|---------------------------------------------------------------------------------------------------
|
||||||
|
IFilterInterceptor | [interface](../blob/master/PoweredSoft.DynamicQuery.Core/IFilterInterceptor.cs) | [test](../blob/master/PoweredSoft.DynamicQuery.Test/TBT.md) | This interceptor allows you to change the behavior of a IFilter being applied to the queryable
|
||||||
|
ISortInterceptor | [interface](../blob/master/PoweredSoft.DynamicQuery.Core/ISortInterceptor.cs) | [test](../blob/master/PoweredSoft.DynamicQuery.Test/TBT.md) | This interceptor allows you to change the behavior of a ISort being applied to the queryable
|
||||||
|
IGroupInterceptor | [interface](../blob/master/PoweredSoft.DynamicQuery.Core/IGroupInterceptor.cs) | [test](../blob/master/PoweredSoft.DynamicQuery.Test/TBT.md) | This interceptor allows you to change the behavior of a IGroup being applied to the queryable
|
||||||
|
IAggregateInterceptor | [interface](../blob/master/PoweredSoft.DynamicQuery.Core/IAggregateInterceptor.cs) | [test](../blob/master/PoweredSoft.DynamicQuery.Test/TBT.md) | This interceptor allows you to change the behavior of a IAggregate being applied to the queryable
|
||||||
|
|
||||||
|
> Post Query execution
|
||||||
|
|
||||||
|
Interceptor | Interface | Example | Description
|
||||||
|
----------------------------------|---------------------------------------------------------------------------------------|-------------------------------------------------------------|------------------------------------------------------------------------------------------------
|
||||||
|
IQueryConvertInterceptor | [interface](../blob/master/PoweredSoft.DynamicQuery.Core/IQueryConvertInterceptor.cs) | [test](../blob/master/PoweredSoft.DynamicQuery.Test/TBT.md) | This interceptor allows you to replace the object that is being returned by the query, by another object instance
|
||||||
|
IQueryConvertInterceptor<T> | [interface](../blob/master/PoweredSoft.DynamicQuery.Core/IQueryConvertInterceptor.cs) | [test](../blob/master/PoweredSoft.DynamicQuery.Test/TBT.md) | This interceptor allows you to replace the object that is being returned by the query, by another object instance
|
Loading…
Reference in New Issue
Block a user