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
# ServiceQuery Allows Querying Data Over REST APIs
8
-
ServiceQuery, https://ServiceQuery.com, is an open-source library that allows dynamically querying database information over REST APIs. Similar to how OData and GraphQL work, it leverages the power of an expressions builder and a simple model that is capable of serializing query instructions over service boundaries. It supports numerous popular relational (SQL) and document (NoSQL) database engines that expose an IQueryable interface. ServiceQuery builds LINQ expressions using individually mapped functions and parsed data that eliminates injection attacks, so querying your data is safe and secure. This library provides clients and front end applications unprecedented queryability using a standardized endpoint supporting polyglot data access.
7
+
# ServiceQuery: Dynamic Data Querying Over REST APIs
8
+
## Overview
9
+
Welcome to [ServiceQuery](https://ServiceQuery.com), the open-source library designed to revolutionize your data querying over REST APIs. Similar to OData and GraphQL, ServiceQuery harnesses the power of an expression builder and a straightforward model to serialize query instructions across service boundaries. It seamlessly supports a wide array of popular relational (SQL) and document (NoSQL) database engines, ensuring secure and efficient data querying by eliminating injection attacks. With ServiceQuery, your clients and front-end applications gain unprecedented querying capabilities through a standardized endpoint supporting polyglot data access.
9
10
10
-
# Installation Instructions
11
-
Install the NuGet Package <b>ServiceQuery</b>
11
+
## Get Started
12
+
### Installation is simple:
13
+
Install the NuGet Package **ServiceQuery**
12
14
13
-
# Examples
14
-
We have numerous examples built using the most popular database storage providers, such as Azure Data Tables, Cosmos DB, MongoDB, MySQL, SQLite, SQL Server, PostgreSQL, Oracle and more!
15
-
View all our examples in the [examples](https://github.com/holomodular/ServiceQuery/blob/main/examples) folder in this project.
15
+
## Why ServiceQuery?
16
+
***Versatile:** Supports numerous database engines including Azure Data Tables, Cosmos DB, MongoDB, MySQL, SQLite, SQL Server, PostgreSQL, Oracle, and more.
17
+
***Secure:** Builds LINQ expressions using individually mapped functions and parsed data, eliminating injection attacks.
18
+
***Powerful:** Provides clients and front-end applications with unprecedented querying capabilities.
16
19
17
-
#Feedback
18
-
We want to hear from our users. Please feel free to post any issues or questions on our discussion board. You can star our repository or you can also reach us at: Support@HoloModular.com
20
+
## Examples
21
+
Explore our [examples folder](https://github.com/holomodular/ServiceQuery/blob/main/examples/V2) for detailed implementations using the most popular database storage providers.
19
22
20
-
# Simple Example - Dynamic Querying Using Javascript
21
-
Modeled based on LINQ, you create a simple request object that is sent over a REST API endpoint to your web server. Make sure to include the following [ServiceQuery.js](https://github.com/holomodular/ServiceQuery/blob/main/src/V2/javascript/servicequery.js) javascript file to quickly build request queries in javascript.
23
+
## We Value Your Feedback
24
+
Join our discussion board to post any questions or issues. Don't forget to star our repository. For direct support, reach us at: Support@HoloModular.com
25
+
26
+
## Dynamic Querying Made Easy
27
+
Here's how you can dynamically query data using JavaScript:
28
+
Make sure to include the following [ServiceQuery.js](https://github.com/holomodular/ServiceQuery/blob/main/src/V2/javascript/servicequery.js) javascript file to quickly build request queries in javascript.
22
29
```javascript
23
30
<script src="/js/servicequery.js"></script>
24
31
<script type="text/javascript">
25
32
26
33
functionGetById() {
27
34
28
-
// Build the request
35
+
// Build the request where id = 123
29
36
var request =newServiceQueryRequestBuilder().IsEqual("Id","123").Build();
30
37
31
-
// Send request to REST API
38
+
// Send ajax request to REST Controller
32
39
$.ajax({
33
-
url:'/api/MyAPI/ExampleServiceQuery',
40
+
url:'/ExampleServiceQuery',
34
41
data:JSON.stringify(request),
35
42
type:"POST",
36
43
dataType:'json',
@@ -44,8 +51,7 @@ Modeled based on LINQ, you create a simple request object that is sent over a RE
44
51
}
45
52
</script>
46
53
```
47
-
On the web server, the request is safely converted into IQueryable expressions that can be executed against several different database engines.
48
-
The following exposes a REST API POST method that the client will call.
54
+
On the server side, convert the request into IQueryable expressions and return the result:
49
55
```csharp
50
56
usingServiceQuery;
51
57
@@ -58,14 +64,15 @@ public ServiceQueryResponse<ExampleTable> ExampleServiceQuery(ServiceQueryReques
58
64
}
59
65
```
60
66
61
-
# Documentation
62
-
Documentation is located on our website at http://ServiceQuery.comas well as a simplified version below. The website also contains tables for supported data types and operations by .NET Framework version and database engine.
67
+
##Documentation
68
+
Comprehensive cocumentation is available on our website at http://ServiceQuery.comincluding tables for supported data types and operations by .NET Framework version and database engine.
63
69
64
70
## ServiceQuery.AzureDataTables
65
-
AzureDataTables does not support several things out of the box, such as aggregates, string comparisons and ordering (solved by downloading all records). We have built a companion NuGet package <b>ServiceQuery.AzureDataTables</b> that provides workarounds to these limitations so you can use all standard operations and execute the request in one line of code. See our example projects for more information.
71
+
Azure Data Tables has certain limitations, like lack of support for aggregate functions, string comparisons and ordering.
72
+
Our companion NuGet package <b>ServiceQuery.AzureDataTables</b> provides a solution to these limitations, allowing you to use standard operations and execute requests seamlessly. The solution is to download all records and then perform the query using an internal list. See our example project for more information.
66
73
67
74
## Building and Executing a Query
68
-
Building a query is accomplished using the ServiceQueryRequestBuilder object to create the request.
75
+
Construct queries using the ServiceQueryRequestBuilder object:
69
76
```csharp
70
77
usingServiceQuery;
71
78
@@ -82,14 +89,14 @@ public void Example()
82
89
```
83
90
84
91
## Supported Operations
85
-
Aggregate Functions
92
+
### Aggregate Functions
86
93
* Average
87
94
* Count
88
95
* Maximum
89
96
* Minimum
90
97
* Sum
91
98
92
-
Comparison Functions
99
+
### Comparison Functions
93
100
* Between
94
101
* Equal
95
102
* Not Equal
@@ -100,31 +107,31 @@ Comparison Functions
100
107
* In Set
101
108
* Not In Set
102
109
103
-
Comparison Functions (string)
110
+
### Comparison Functions (string)
104
111
* Contains
105
112
* StartsWith
106
113
* EndsWith
107
114
108
-
Grouping Functions
115
+
### Grouping Functions
109
116
* And
110
117
* Or
111
118
* Begin
112
119
* End
113
120
114
-
Nullability Functions
121
+
### Nullability Functions
115
122
* Null
116
123
* Not Null
117
124
118
-
Paging Functions
125
+
### Paging Functions
119
126
* Page Number
120
127
* Page Size
121
128
* Include Count
122
129
123
-
Selecting Functions
130
+
### Selecting Functions
124
131
* Distinct
125
132
* Select
126
133
127
-
Sorting Functions
134
+
### Sorting Functions
128
135
* Sort Ascending
129
136
* Sort Descending
130
137
@@ -196,54 +203,26 @@ If you are using javascript, make sure to download the [ServiceQuery.js](https:/
196
203
```
197
204
198
205
## ServiceQuery Options
199
-
We currently provide the following server-side options when processing queries.
206
+
Customize server-side query processing with ServiceQueryOptions object:
200
207
```csharp
201
208
publicclassServiceQueryOptions
202
209
{
203
-
/// <summary>
204
-
/// Dictionary list of property name mappings.
205
-
/// Exposed Class -> Internal Class
206
-
/// Default will use all queryable class property names
/// Determine whether property names must be case sensitive or throw an exception.
212
-
/// Default is false.
213
-
/// </summary>
214
211
publicboolPropertyNameCaseSensitive { get; set; }
215
-
216
-
/// <summary>
217
-
/// Determine if missing BEGIN/END/AND/OR expressions throw an exception
218
-
/// or try to add them missing ones automatiically.
219
-
/// </summary>
220
212
publicboolAllowMissingExpressions { get; set; }
221
213
}
222
214
```
223
215
224
216
## Advanced Usage Scenarios
225
-
There are many benefits to being able to manipulate queries before they are executed. You could:
226
-
227
-
* Restrict properties by user roles
228
-
229
-
When receiving a query, you can use the ServiceQueryOptions to change the list of mapped properties based on the user's security role. If a user specifies a property that is not mapped, such as SSN property, an exception is thrown.
230
-
231
-
Note: You should restrict properties from select, where and orderby filters so that no information can be obtained, filtered, ordered or gleaned in anyway by its usage.
232
-
233
-
* Sharding data
234
-
235
-
When receiving a query, you can add expressions on to the query to make sure that it is only performed against a data segment that you specify, for instance a CustomerKey.
236
-
This would be in the format:
237
217
238
-
**( originalquery ) AND CustomerKey = 123**
218
+
### Manipulate queries before executing them
219
+
Add to, change or remove filters from incoming queries for business reasons.
239
220
240
-
To accomplish this on a ServiceQueryRequest object, perform the following operations:
241
-
1) Add a BEGIN expressions at the first index of the filters
242
-
2) Add an END expression to the end of the list
243
-
3) Add an AND expression to the end of the list
244
-
4) Add an ISEQUAL for property CustomerKey and value 123
221
+
### Restrict properties by user roles
222
+
Adjust property mappings based on user role for security.
245
223
246
-
If the user doesn't pass any where filters, skip steps 1-3. The library will validate queries, ensuring begin and end expressions, their directions and counts match, ensuring users can't craft malicious queries to circumvent this, otherwise an exception is thrown.
224
+
### Sharding data
225
+
Add expressions to queries to target specific data segments, ensuring efficient data retrieval and enhanced security.
247
226
248
-
# About
249
-
I am a business executive and software architect with over 26 years professional experience. You can reach me via www.linkedin.com/in/danlogsdon or https://HoloModular.com
227
+
##About
228
+
I am a business executive and software architect with 25+ years professional experience. You can reach me via www.linkedin.com/in/danlogsdon or visithttps://HoloModular.com
0 commit comments