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

Commit 147643b

Browse files
author
Ihar Yakimush
committed
Merge branch 'develop' of https://github.com/IharYakimush/comminity-data-odata-linq into develop
2 parents 0f4b368 + 7c874b5 commit 147643b

File tree

1 file changed

+59
-4
lines changed

1 file changed

+59
-4
lines changed

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)

0 commit comments

Comments
 (0)