Skip to content
This repository was archived by the owner on Feb 17, 2025. It is now read-only.

Commit 51ba9f5

Browse files
author
IharYakimush
authored
Merge pull request #1 from IharYakimush/develop
PR
2 parents a62038c + 147643b commit 51ba9f5

File tree

5 files changed

+126
-16
lines changed

5 files changed

+126
-16
lines changed

Community.Data.OData.Linq.xTests/Community.OData.Linq.xTests.csproj

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,24 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>netcoreapp2.0</TargetFramework>
4+
<TargetFrameworks>netcoreapp2.0;net45</TargetFrameworks>
55

66
<IsPackable>false</IsPackable>
77

88
<SignAssembly>false</SignAssembly>
99

10-
<AssemblyOriginatorKeyFile>Sign.pfx</AssemblyOriginatorKeyFile>
10+
<ApplicationIcon />
11+
12+
<OutputType>Library</OutputType>
13+
14+
<StartupObject />
1115
</PropertyGroup>
1216

1317
<ItemGroup>
1418
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.5.0" />
1519
<PackageReference Include="Microsoft.OData.Core" Version="7.4.0" />
1620
<PackageReference Include="xunit" Version="2.3.1" />
21+
<PackageReference Include="xunit.runner.console" Version="2.3.1" />
1722
<PackageReference Include="xunit.runner.visualstudio" Version="2.3.1" />
1823
<DotNetCliToolReference Include="dotnet-xunit" Version="2.3.1" />
1924
</ItemGroup>

Community.Data.OData.Linq.xTests/OrderByTests.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55

66
namespace Community.OData.Linq.xTests
77
{
8+
using System;
9+
810
public class OrderByTests
911
{
1012
[Fact]
@@ -47,11 +49,11 @@ public void OrderByIdCaseSensitiveConfig()
4749
}
4850

4951

50-
[Fact]
52+
[Fact, Trait("Category", "A")]
5153
public void OrderByNotSortable()
5254
{
53-
Assert.Throws<ODataException>(() =>
54-
SimpleClass.CreateQuery().OData().OrderBy($"{nameof(SimpleClass.NotOrderable)}"));
55+
Assert.Throws<ODataException>(
56+
() => SimpleClass.CreateQuery().OData().OrderBy($"{nameof(SimpleClass.NotOrderable)}"));
5557
}
5658
}
5759
}
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
namespace Readme
2+
{
3+
using System;
4+
using System.Linq;
5+
using Community.OData.Linq;
6+
7+
public class Sample
8+
{
9+
public int Id { get; set; }
10+
11+
public string Name { get; set; }
12+
}
13+
14+
public class Demo
15+
{
16+
public void SimpleFilter()
17+
{
18+
IQueryable<Sample> dataSet = this.CreateQuerable();
19+
Sample[] filterResult = dataSet.OData().Filter("Id eq 2 or Name eq 'name3'").ToArray();
20+
21+
// Id:2 Name:name2
22+
// Id:3 Name:name3
23+
foreach (Sample sample in filterResult)
24+
{
25+
Console.WriteLine(string.Format("Id:{0} Name:{1}", sample.Id, sample.Name));
26+
}
27+
}
28+
29+
public void SimpleOrderBy()
30+
{
31+
IQueryable<Sample> dataSet = this.CreateQuerable();
32+
Sample[] filterResult = dataSet.OData().OrderBy("Id desc").ToArray();
33+
34+
// Id:3 Name:name3
35+
// Id:2 Name:name2
36+
// Id:1 Name:name1
37+
foreach (Sample sample in filterResult)
38+
{
39+
Console.WriteLine(string.Format("Id:{0} Name:{1}", sample.Id, sample.Name));
40+
}
41+
}
42+
43+
private IQueryable<Sample> CreateQuerable()
44+
{
45+
return new[]
46+
{
47+
new Sample { Id = 1, Name = "name1" },
48+
new Sample { Id = 2, Name = "name2" },
49+
new Sample { Id = 3, Name = "name3" },
50+
}.AsQueryable();
51+
}
52+
}
53+
}

README.md

Lines changed: 59 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,62 @@
1-
# comminity-odata-linq
1+
# Community.OData.Linq
22
Use text (OData format) expressons in LINQ methods for any IQuerable
3-
# build status
4-
[![Build status](https://ci.appveyor.com/api/projects/status/yrmp3074ryce61gb/branch/develop?svg=true)](https://ci.appveyor.com/project/IharYakimush/comminity-data-odata-linq/branch/develop)
53

4+
# Sample
5+
Please check simple code below to get started
6+
```
7+
using System;
8+
using System.Linq;
9+
using Community.OData.Linq;
10+
11+
public class Sample
12+
{
13+
public int Id { get; set; }
14+
15+
public string Name { get; set; }
16+
}
17+
18+
public class Demo
19+
{
20+
public void SimpleFilter()
21+
{
22+
IQueryable<Sample> dataSet = this.CreateQuerable();
23+
Sample[] filterResult = dataSet.OData().Filter("Id eq 2 or Name eq 'name3'").ToArray();
24+
25+
// Id:2 Name:name2
26+
// Id:3 Name:name3
27+
foreach (Sample sample in filterResult)
28+
{
29+
Console.WriteLine(string.Format("Id:{0} Name:{1}", sample.Id, sample.Name));
30+
}
31+
}
632
7-
# nuget
33+
public void SimpleOrderBy()
34+
{
35+
IQueryable<Sample> dataSet = this.CreateQuerable();
36+
Sample[] filterResult = dataSet.OData().OrderBy("Id desc").ToArray();
37+
38+
// Id:3 Name:name3
39+
// Id:2 Name:name2
40+
// Id:1 Name:name1
41+
foreach (Sample sample in filterResult)
42+
{
43+
Console.WriteLine(string.Format("Id:{0} Name:{1}", sample.Id, sample.Name));
44+
}
45+
}
46+
47+
private IQueryable<Sample> CreateQuerable()
48+
{
49+
return new[]
50+
{
51+
new Sample { Id = 1, Name = "name1" },
52+
new Sample { Id = 2, Name = "name2" },
53+
new Sample { Id = 3, Name = "name3" },
54+
}.AsQueryable();
55+
}
56+
}
57+
```
58+
# Nuget
59+
https://www.nuget.org/packages/Community.OData.Linq
60+
61+
# Build Status
62+
[![Build status](https://ci.appveyor.com/api/projects/status/yrmp3074ryce61gb/branch/develop?svg=true)](https://ci.appveyor.com/project/IharYakimush/comminity-data-odata-linq/branch/develop)

build.ps1

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,2 @@
1-
if(Test-Path .\artifacts) { Remove-Item .\artifacts -Force -Recurse }
2-
3-
dotnet restore .\Community.Data.OData.Linq\Community.OData.Linq.csproj
4-
5-
dotnet build .\Community.Data.OData.Linq\Community.OData.Linq.csproj -c Release
6-
7-
dotnet pack .\Community.Data.OData.Linq\Community.OData.Linq.csproj -c Release -o ..\artifacts
1+
dotnet restore .\Community.Data.OData.Linq.sln
2+
dotnet build .\Community.Data.OData.Linq.sln -c Release

0 commit comments

Comments
 (0)