You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: README.md
+7-9
Original file line number
Diff line number
Diff line change
@@ -104,17 +104,15 @@ Now you need to create async method that will serve OData requests with followin
104
104
First, you need to parse Request parameters using UriParser in order to extract the definition of query (QuerySpec object). Then you need to use QueryBuilder to create SQL query using the QuerySpec. Then you need to provide sql query to QueryPipe that will stream results to client using Response.Body:
105
105
106
106
```
107
-
// GET api/People
108
-
[HttpGet]
109
-
public async Task Get()
110
-
{
111
-
var querySpec = OData.UriParser.Parse(tableSpec, this.Request);
112
-
var sql = QueryBuilder.Build(querySpec, tableSpec).AsJson();
113
-
await sqlQuery.Stream(sql, Response.Body, "[]");
114
-
}
107
+
public async Task OData()
108
+
{
109
+
await this
110
+
.ODataHandler(tableSpec, pipe)
111
+
.Process();
112
+
}
115
113
```
116
114
117
-
That's everything that you need to do. With three lines of code you can create OData service on any table.
115
+
That's everything that you need to do. With three lines of code you can create OData service on any table. You can find more more details in [OData documentation](doc/odata.md) page.
118
116
119
117
## Implement REST service that process JQuery DataTables Ajax request
Copy file name to clipboardexpand all lines: doc/odata.md
+123-1
Original file line number
Diff line number
Diff line change
@@ -21,7 +21,7 @@ OData services implemented using Sql Server REST API library provide minimal int
21
21
query data without additional overhead introduced by advanced OData operators (e.g. $extend, all/any), or verbose response format.
22
22
23
23
> The goal of this project is not to support all standard OData features. Library provides the most important features, and
24
-
> excludes features that cannot provide . The most important benefits that this library provides are simplicity and speed.
24
+
> excludes features that cannot provide optimal performance. The most important benefits that this library provides are simplicity and speed.
25
25
> If you need full compatibility with official OData spec, you can chose other implementations.
26
26
27
27
# Metadata information
@@ -30,3 +30,125 @@ OData services implemented using Sql Server REST API library return minimal resp
30
30
OData spec (aka. metadata-none format).
31
31
In this library is supported only minimal output format that do not include any metadata information in the REST API body.
32
32
33
+
# Implement OData service
34
+
35
+
OData service can be implemented using any .Net project, such ASP.NET Core, ASP.NET Web Api, Azure Function (C#). You just need to reference nuget package in project.json file:
36
+
37
+
''project.json''
38
+
```
39
+
{
40
+
"frameworks": {
41
+
"net46":{
42
+
"dependencies": {
43
+
"Antlr4.Runtime": "4.5.3",
44
+
"Sql-Server-Rest-Api": "0.2.7"
45
+
}
46
+
}
47
+
}
48
+
}
49
+
```
50
+
This setting will take Sql Server Rest Api from NuGet and also load Antlr4.Runtime that is used to parse requests. Once you reference these nuget packages, you can create your OData service.
51
+
52
+
## OData service and ASP.NET Core
53
+
54
+
You can implement OData service using ASP.NET Core application as a method of any controller.
55
+
First, you need to setup Sql Client in Startup class:
56
+
- Add the reference to ''SqlServerRestApi'' in Startup class
57
+
- Initialize SqlClient component that will be used to read data from table and return it as OData response.
58
+
59
+
Example of code is shown in the following listing:
60
+
61
+
''Startup.cs''
62
+
```
63
+
using SqlServerRestApi;
64
+
65
+
namespace MyMvcApp
66
+
{
67
+
public class Startup {
68
+
69
+
// This method gets called by the runtime. Use this method to add services to the container.
70
+
public void ConfigureServices(IServiceCollection services)
0 commit comments