-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12 from ZEXSM/feature/coverage
Update readme
- Loading branch information
Showing
6 changed files
with
194 additions
and
180 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,45 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio 15 | ||
VisualStudioVersion = 15.0.28307.705 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{FA1582AB-A13D-44A4-A46D-2DAE1111A2BB}" | ||
EndProject | ||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{26982440-340F-48A2-9D73-44DB6C52EBF1}" | ||
EndProject | ||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OData.QueryBuilder", "src\OData.QueryBuilder\OData.QueryBuilder.csproj", "{E4D8F027-2B79-4794-9B75-D08C2BA066B8}" | ||
EndProject | ||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OData.QueryBuilder.Test", "test\OData.QueryBuilder.Test\OData.QueryBuilder.Test.csproj", "{537E849E-5291-49F9-BD2A-9F4A01DB1561}" | ||
EndProject | ||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "items", "items", "{179F88B9-A06D-4505-9266-A5D66004601C}" | ||
ProjectSection(SolutionItems) = preProject | ||
.travis.yml = .travis.yml | ||
README.md = README.md | ||
EndProjectSection | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{E4D8F027-2B79-4794-9B75-D08C2BA066B8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{E4D8F027-2B79-4794-9B75-D08C2BA066B8}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{E4D8F027-2B79-4794-9B75-D08C2BA066B8}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{E4D8F027-2B79-4794-9B75-D08C2BA066B8}.Release|Any CPU.Build.0 = Release|Any CPU | ||
{537E849E-5291-49F9-BD2A-9F4A01DB1561}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{537E849E-5291-49F9-BD2A-9F4A01DB1561}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{537E849E-5291-49F9-BD2A-9F4A01DB1561}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{537E849E-5291-49F9-BD2A-9F4A01DB1561}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(NestedProjects) = preSolution | ||
{E4D8F027-2B79-4794-9B75-D08C2BA066B8} = {FA1582AB-A13D-44A4-A46D-2DAE1111A2BB} | ||
{537E849E-5291-49F9-BD2A-9F4A01DB1561} = {26982440-340F-48A2-9D73-44DB6C52EBF1} | ||
EndGlobalSection | ||
GlobalSection(ExtensibilityGlobals) = postSolution | ||
SolutionGuid = {1D51B9A3-94B0-48DF-BFF5-110B13303535} | ||
EndGlobalSection | ||
EndGlobal | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio 15 | ||
VisualStudioVersion = 15.0.28307.705 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{FA1582AB-A13D-44A4-A46D-2DAE1111A2BB}" | ||
EndProject | ||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{26982440-340F-48A2-9D73-44DB6C52EBF1}" | ||
EndProject | ||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OData.QueryBuilder", "src\OData.QueryBuilder\OData.QueryBuilder.csproj", "{E4D8F027-2B79-4794-9B75-D08C2BA066B8}" | ||
EndProject | ||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OData.QueryBuilder.Test", "test\OData.QueryBuilder.Test\OData.QueryBuilder.Test.csproj", "{537E849E-5291-49F9-BD2A-9F4A01DB1561}" | ||
EndProject | ||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "items", "items", "{179F88B9-A06D-4505-9266-A5D66004601C}" | ||
ProjectSection(SolutionItems) = preProject | ||
.travis.yml = .travis.yml | ||
README.md = README.md | ||
EndProjectSection | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{E4D8F027-2B79-4794-9B75-D08C2BA066B8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{E4D8F027-2B79-4794-9B75-D08C2BA066B8}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{E4D8F027-2B79-4794-9B75-D08C2BA066B8}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{E4D8F027-2B79-4794-9B75-D08C2BA066B8}.Release|Any CPU.Build.0 = Release|Any CPU | ||
{537E849E-5291-49F9-BD2A-9F4A01DB1561}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{537E849E-5291-49F9-BD2A-9F4A01DB1561}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{537E849E-5291-49F9-BD2A-9F4A01DB1561}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{537E849E-5291-49F9-BD2A-9F4A01DB1561}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(NestedProjects) = preSolution | ||
{E4D8F027-2B79-4794-9B75-D08C2BA066B8} = {FA1582AB-A13D-44A4-A46D-2DAE1111A2BB} | ||
{537E849E-5291-49F9-BD2A-9F4A01DB1561} = {26982440-340F-48A2-9D73-44DB6C52EBF1} | ||
EndGlobalSection | ||
GlobalSection(ExtensibilityGlobals) = postSolution | ||
SolutionGuid = {1D51B9A3-94B0-48DF-BFF5-110B13303535} | ||
EndGlobalSection | ||
EndGlobal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,100 +1,105 @@ | ||
# OData.QueryBuilder | ||
Библиотека позволяющая собрать OData запрос на основе модели данных | ||
|
||
[![Build Status](https://travis-ci.com/ZEXSM/OData.QueryBuilder.svg?branch=master)](https://travis-ci.com/ZEXSM/OData.QueryBuilder) | ||
[![Coverage Status](https://coveralls.io/repos/github/ZEXSM/OData.QueryBuilder/badge.svg?branch=master)](https://coveralls.io/github/ZEXSM/OData.QueryBuilder?branch=master) | ||
[![Nuget Status](https://img.shields.io/nuget/dt/OData.QueryBuilder.svg)](https://www.nuget.org/packages/OData.QueryBuilder) | ||
|
||
## Установка | ||
Чтобы установить `OData.QueryBuilder` из `Visual Studio`, найдите `OData.QueryBuilder` в пользовательском интерфейсе диспетчера пакетов `NuGet` или выполните следующую команду в консоли диспетчера пакетов: | ||
``` | ||
Install-Package OData.QueryBuilder -Version 1.0.0 | ||
``` | ||
|
||
Чтобы добавить ссылку на основной проект `dotnet`, выполните в командной строке следующее: | ||
|
||
``` | ||
dotnet add -v 1.0.0 OData.QueryBuilder | ||
``` | ||
|
||
## Использование | ||
|
||
1. Создать экземпляр билдера | ||
|
||
Преждем чем начать строить `OData` запрос, необходимо создать новый экземпляр объекта `OData.QueryBuilder` с указанием модели данных и базового пути: | ||
|
||
```charp | ||
var odataQueryBuilder = new ODataQueryBuilder<Модель данных сущностей>(<base_url>); | ||
``` | ||
|
||
2. Указать ресурс для которого будет строиться запрос | ||
|
||
```charp | ||
odataQueryBuilder.For<Модель сущности>(s => s.<ресурс>) | ||
``` | ||
|
||
3. Выборать тип запроса | ||
|
||
Билдер позволяет строить запросы по ключу и списку. | ||
* ByKey(<ключ>) | ||
* Expand | ||
* Select | ||
* ToUri | ||
* ByList() | ||
* Expand | ||
* Filter | ||
* Select | ||
* OrderBy | ||
* OrderByDescending | ||
* Top | ||
* Skip | ||
* Count | ||
* ToUri | ||
4. Получить Uri запроса от билдера | ||
```charp | ||
odataQueryBuilder.ToUri() | ||
``` | ||
|
||
## Примеры | ||
|
||
#### ByKey - по ключу | ||
1. Запрос по ключу с простым `Expand` | ||
```charp | ||
var uri = new ODataQueryBuilder<ODataInfoContainer>("http://mock/odata") | ||
.For<ODataTypeEntity>(s => s.ODataType) | ||
.ByKey(223123123) | ||
.Expand(s => s.ODataKind) | ||
.ToUri(); | ||
``` | ||
> http://mock/odata/ODataType(223123123)?$expand=ODataKind | ||
2. Запрос по ключу с вложенными `Expand` и `Select` | ||
```charp | ||
var uri = new ODataQueryBuilder<ODataInfoContainer>("http://mock/odata") | ||
.For<ODataTypeEntity>(s => s.ODataType) | ||
.ByKey(223123123) | ||
.Expand(f => | ||
{ | ||
f.For<ODataKindEntity>(s => s.ODataKind) | ||
.Expand(ff => ff.For<ODataCodeEntity>(s => s.ODataCode) | ||
.Select(s => s.IdCode)); | ||
f.For<ODataKindEntity>(s => s.ODataKindNew) | ||
.Select(s => s.IdKind); | ||
f.For<ODataKindEntity>(s => s.ODataKindNew) | ||
.Select(s => s.IdKind); | ||
}) | ||
.Select(s => new { s.IdType, s.Sum }) | ||
.ToUri(); | ||
``` | ||
> http://mock/odata/ODataType(223123123)?$expand=ODataKind($expand=ODataCode($select=IdCode)),ODataKindNew($select=IdKind),ODataKindNew($select=IdKind)&$select=IdType,Sum | ||
#### ByList - по списку | ||
1. Запрос по списку с простым `Expand` | ||
```charp | ||
var uri = new ODataQueryBuilder<ODataInfoContainer>("http://mock/odata") | ||
.For<ODataTypeEntity>(s => s.ODataType) | ||
.ByList() | ||
.Expand(s => new { s.ODataKind }) | ||
.ToUri(); | ||
``` | ||
> http://mock/odata/ODataType?$expand=ODataKind | ||
# OData.QueryBuilder | ||
Library provides linq syntax and allows you to build OData queries based on the data model | ||
|
||
[![Build Status](https://travis-ci.com/ZEXSM/OData.QueryBuilder.svg?branch=master)](https://travis-ci.com/ZEXSM/OData.QueryBuilder) | ||
[![Coverage Status](https://coveralls.io/repos/github/ZEXSM/OData.QueryBuilder/badge.svg?branch=master)](https://coveralls.io/github/ZEXSM/OData.QueryBuilder?branch=master) | ||
[![Nuget Status](https://img.shields.io/nuget/dt/OData.QueryBuilder.svg)](https://www.nuget.org/packages/OData.QueryBuilder) | ||
|
||
## Benefits | ||
* Expression is not used to `Compile()`, which generates `MSIL` code, which leads to memory leaks | ||
* Support for nested `OData` extenders with a choice of filtering | ||
* Support `OData` functions `Date`, `Any`, `All` | ||
* Support `OData` operator `IN` | ||
|
||
## Installation | ||
To install `OData.QueryBuilder` from` Visual Studio`, find `OData.QueryBuilder` in the` NuGet` package manager user interface or enter the following command in the package manager console: | ||
``` | ||
Install-Package OData.QueryBuilder -Version 1.0.0 | ||
``` | ||
|
||
To add a link to the main dotnet project, run the following command line: | ||
``` | ||
dotnet add -v 1.0.0 OData.QueryBuilder | ||
``` | ||
|
||
## Usage | ||
|
||
1. Build instance | ||
|
||
As soon as possible, create a new instance of the OData.QueryBuilder object indicating the data models and the base path: | ||
|
||
```csharp | ||
var odataQueryBuilder = new ODataQueryBuilder<Your entity model>(<base_url>); | ||
``` | ||
|
||
2. Specify the resource for which the request will be built | ||
|
||
```csharp | ||
odataQueryBuilder.For<Your data model>(s => s.<Your resource model>) | ||
``` | ||
|
||
3. Select request type | ||
|
||
The builder allows you to build queries on the key and the list: | ||
* ByKey(<Key>) | ||
* Expand | ||
* Select | ||
* ToUri | ||
* ByList() | ||
* Expand | ||
* Filter | ||
* Select | ||
* OrderBy | ||
* OrderByDescending | ||
* Top | ||
* Skip | ||
* Count | ||
* ToUri | ||
4. Get a Uri request from the builder | ||
```csharp | ||
odataQueryBuilder.ToUri() | ||
``` | ||
|
||
## Examples | ||
|
||
#### By key | ||
1. Key request with a simple `Expand` | ||
```csharp | ||
var uri = new ODataQueryBuilder<ODataInfoContainer>("http://mock/odata") | ||
.For<ODataTypeEntity>(s => s.ODataType) | ||
.ByKey(223123123) | ||
.Expand(s => s.ODataKind) | ||
.ToUri(); | ||
``` | ||
> http://mock/odata/ODataType(223123123)?$expand=ODataKind | ||
2. Key request with nested `Expand` и `Select` | ||
```csharp | ||
var uri = new ODataQueryBuilder<ODataInfoContainer>("http://mock/odata") | ||
.For<ODataTypeEntity>(s => s.ODataType) | ||
.ByKey(223123123) | ||
.Expand(f => | ||
{ | ||
f.For<ODataKindEntity>(s => s.ODataKind) | ||
.Expand(ff => ff.For<ODataCodeEntity>(s => s.ODataCode) | ||
.Select(s => s.IdCode)); | ||
f.For<ODataKindEntity>(s => s.ODataKindNew) | ||
.Select(s => s.IdKind); | ||
f.For<ODataKindEntity>(s => s.ODataKindNew) | ||
.Select(s => s.IdKind); | ||
}) | ||
.Select(s => new { s.IdType, s.Sum }) | ||
.ToUri(); | ||
``` | ||
> http://mock/odata/ODataType(223123123)?$expand=ODataKind($expand=ODataCode($select=IdCode)),ODataKindNew($select=IdKind),ODataKindNew($select=IdKind)&$select=IdType,Sum | ||
#### By list | ||
1. Query list with a simple `Expand` | ||
```csharp | ||
var uri = new ODataQueryBuilder<ODataInfoContainer>("http://mock/odata") | ||
.For<ODataTypeEntity>(s => s.ODataType) | ||
.ByList() | ||
.Expand(s => new { s.ODataKind }) | ||
.ToUri(); | ||
``` | ||
> http://mock/odata/ODataType?$expand=ODataKind |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,16 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<IsPackable>true</IsPackable> | ||
<TargetFramework>netstandard1.3</TargetFramework> | ||
<NuspecFile>bin\$(Configuration)\$(TargetFramework)\OData.QueryBuilder.nuspec</NuspecFile> | ||
<NuspecProperties>version=$(PackageVersion)</NuspecProperties> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<None Update="OData.QueryBuilder.nuspec"> | ||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> | ||
</None> | ||
</ItemGroup> | ||
</Project> | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<IsPackable>true</IsPackable> | ||
<TargetFramework>netstandard1.3</TargetFramework> | ||
<NuspecFile>bin\$(Configuration)\$(TargetFramework)\OData.QueryBuilder.nuspec</NuspecFile> | ||
<NuspecProperties>version=$(PackageVersion)</NuspecProperties> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<DotNetCliToolReference Include="MiniCover" Version="2.0.0-ci-20181108093139" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<None Update="OData.QueryBuilder.nuspec"> | ||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> | ||
</None> | ||
</ItemGroup> | ||
</Project> |
Oops, something went wrong.