Skip to content

Commit a000954

Browse files
Readme.md improvements (#7)
* Readme.md improved * Readme.md inconsistencies fixed.
1 parent e44668e commit a000954

File tree

1 file changed

+75
-5
lines changed

1 file changed

+75
-5
lines changed

README.md

Lines changed: 75 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,13 @@
66

77
## Overview
88

9-
SoftwareOne.Rql is a high-performance implementation of [Resource Query Language (RQL)](https://docs.platform.softwareone.com/developer-resources/rest-api/resource-query-language) for .NET applications. It enables API consumers to efficiently filter, sort, and paginate data with an intuitive and expressive syntax, delivering precise data retrieval capabilities.
9+
Mpt.Rql is a high-performance implementation of [Resource Query Language (RQL)](https://docs.platform.softwareone.com/developer-resources/rest-api/resource-query-language) for .NET applications. It enables API consumers to efficiently filter, sort, and paginate data with an intuitive and expressive syntax, delivering precise data retrieval capabilities.
1010

1111
## Features
1212

13-
- **Advanced Filtering** - Support for complex logical expressions (AND, OR, NOT)
14-
- **Dynamic Sorting** - Multiple fields with ascending/descending options
15-
- **Pagination** - Skip and limit results for efficient data loading
16-
- **Field Selection** - Return only required fields to minimize payload size
13+
- **Filtering** - Support for complex logical expressions
14+
- **Sorting** - Multiple fields with ascending/descending options
15+
- **Projections** - Return only required fields to minimize payload size
1716
- **LINQ Integration** - Seamless integration with Entity Framework and other LINQ providers
1817
- **Validation** - Comprehensive error handling and input validation
1918
- **Performance Optimized** - Efficient query processing for minimal overhead
@@ -42,6 +41,77 @@ public void ConfigureServices(IServiceCollection services)
4241
}
4342
```
4443

44+
### Applying RQL to IQueryable<>
45+
```csharp
46+
public class UserQueryBuilder(IRqlQueryable<User> rql)
47+
{
48+
public IQueryable<User> GetUsersOlderThan(IQueryable<User> sourceQuery, int age)
49+
{
50+
var request = new RqlRequest
51+
{
52+
Filter = $"gt(age,{age})", // Age must be greater than age specified
53+
Order = "-age", // Order by age desc
54+
Select = "id,name" // Select id and name
55+
};
56+
57+
var response = rql.Transform(sourceQuery, request);
58+
59+
if (response.IsSuccess)
60+
return response.Query; // Return transformed query
61+
62+
response.Errors.ForEach(t => { }); // Iterate through transformation errors (optional)
63+
64+
Console.WriteLine(response.Graph.Print()) // Visualize the decision graph (optional)
65+
}
66+
}
67+
```
68+
69+
## Using RQL mapping
70+
In many projects, developers prefer to keep database entities separate from data transfer objects (DTOs), especially when their structures differ. To support this approach, Mpt.Rql includes built-in mapping functionality, which is enabled by default and relies on name-based matching. For more advanced scenarios, custom mappings can also be defined manually
71+
72+
### Configure RQL
73+
```csharp
74+
public void ConfigureServices(IServiceCollection services)
75+
{
76+
services.AddRql(options =>
77+
{
78+
// Instruct RQL to look for mappers in specific asembly
79+
options.ScanForMappers(typeof(Program).Assembly);
80+
});
81+
}
82+
```
83+
84+
### Specify mapping
85+
```csharp
86+
internal class UserMapper : IRqlMapper<DbUser, User>
87+
{
88+
public void MapEntity(IRqlMapperContext<DbUser, User> context)
89+
{
90+
context
91+
.MapStatic(t => t.Id, t => t.UserId)
92+
.MapStatic(t => t.Age, t => t.AgeInYears);
93+
}
94+
}
95+
```
96+
97+
### Apply RQL
98+
```csharp
99+
public class UserQueryBuilder(IRqlQueryable<DbUser, User> rql)
100+
{
101+
public IQueryable<User> GetUsersOlderThan(IQueryable<DbUser> sourceQuery, int age)
102+
{
103+
var request = new RqlRequest
104+
{
105+
Filter = $"gt(age,{age})", // Age must be greater than age specified
106+
Order = "-age", // Order by age desc
107+
Select = "id,name" // Select id and name
108+
};
109+
110+
return rql.Transform(sourceQuery, request).Query;
111+
}
112+
}
113+
```
114+
45115
## Contributing
46116

47117
We welcome contributions to enhance the library. Please see our Contributing Guide for details:

0 commit comments

Comments
 (0)