Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ private class SqlEntity
}

private IMappingRegistry _registry = null!;
private ISqlDialect _dialect = null!;
private SqlTranslator _translator = null!;
private QueryOptions _simpleOptions = null!;
private QueryOptions _complexFilterOptions = null!;
Expand All @@ -41,8 +40,7 @@ public void Setup()
_registry = new MappingRegistry();
_registry.Entity<SqlEntity>().ToTable("SqlEntities");

_dialect = new SqlServerDialect();
_translator = new SqlTranslator(_registry, _dialect);
_translator = new SqlTranslator(_registry, new SqlServerDialect());

_simpleOptions = BuildSimpleQuery();
_complexFilterOptions = BuildComplexFilterQuery();
Expand Down
13 changes: 8 additions & 5 deletions docs/examples/advanced.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,16 @@ OFFSET 0 ROWS FETCH NEXT 20 ROWS ONLY
**Response:**
```json
{
"totalCount": 2,
"resultCount": 2,
"page": 1,
"pageSize": 20,
"aggregates": null,
"data": [
{ "id": 1, "name": "Alice Chen" },
{ "id": 5, "name": "Carol White" }
],
"totalCount": 2,
"page": 1,
"pageSize": 20
"nextCursorToken": null
}
```

Expand Down Expand Up @@ -274,7 +277,7 @@ GET /api/users?select=id,name,salary
public async Task<IActionResult> GetOrders([FromQuery] FlexQueryParameters parameters, CancellationToken ct)
{
// Parse
var options = QueryOptionsParser.Parse(parameters);
var options = parameters.ToQueryOptions();

// Validate
var execOptions = new QueryExecutionOptions
Expand All @@ -296,7 +299,7 @@ public async Task<IActionResult> GetOrders([FromQuery] FlexQueryParameters param
var total = await query.CountAsync(ct);

query = query.ApplyPaging(options);
query = query.ApplyFilteredIncludes(options);
query = query.ApplyExpand(options);

var data = await query.ApplySelect(options).ToListAsync(ct);

Expand Down
55 changes: 41 additions & 14 deletions docs/examples/basic.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,20 @@ public async Task<IActionResult> GetUsers([FromQuery] FlexQueryParameters parame
**Response:**
```json
{
"totalCount": 42,
"resultCount": 42,
"page": 1,
"pageSize": 20,
"totalPages": 3,
"hasNextPage": true,
"hasPreviousPage": false,
"aggregates": null,
"data": [
{ "id": 1, "name": "Alice Chen", "email": "alice@example.com", "status": "active", "createdAt": "2024-03-15T10:00:00Z" },
{ "id": 2, "name": "Bob Smith", "email": "bob@example.com", "status": "active", "createdAt": "2024-04-01T09:30:00Z" },
{ "id": 5, "name": "Carol White", "email": "carol@example.com", "status": "active", "createdAt": "2024-04-20T14:00:00Z" }
],
"totalCount": 42,
"page": 1,
"pageSize": 20
"nextCursorToken": null
}
```

Expand All @@ -64,14 +70,20 @@ OFFSET 0 ROWS FETCH NEXT 10 ROWS ONLY
**Response:**
```json
{
"totalCount": 3,
"resultCount": 3,
"page": 1,
"pageSize": 10,
"totalPages": 1,
"hasNextPage": false,
"hasPreviousPage": false,
"aggregates": null,
"data": [
{ "id": 1, "name": "Alice Chen", "status": "active" },
{ "id": 8, "name": "Ali Hassan", "status": "active" },
{ "id": 12, "name": "Alicia Park", "status": "inactive" }
],
"totalCount": 3,
"page": 1,
"pageSize": 10
"nextCursorToken": null
}
```

Expand All @@ -98,13 +110,19 @@ OFFSET 0 ROWS FETCH NEXT 50 ROWS ONLY
**Response:**
```json
{
"totalCount": 42,
"resultCount": 42,
"page": 1,
"pageSize": 50,
"totalPages": 1,
"hasNextPage": false,
"hasPreviousPage": false,
"aggregates": null,
"data": [
{ "id": 1, "name": "Alice Chen", "email": "alice@example.com" },
{ "id": 2, "name": "Bob Smith", "email": "bob@example.com" }
],
"totalCount": 42,
"page": 1,
"pageSize": 50
"nextCursorToken": null
}
```

Expand Down Expand Up @@ -134,13 +152,19 @@ GET /api/users?query=(name = "alice" OR name = "bob") AND status = "active"&page
**Response:**
```json
{
"totalCount": 2,
"resultCount": 2,
"page": 1,
"pageSize": 10,
"totalPages": 1,
"hasNextPage": false,
"hasPreviousPage": false,
"aggregates": null,
"data": [
{ "id": 1, "name": "Alice Chen", "status": "active" },
{ "id": 2, "name": "Bob Smith", "status": "active" }
],
"totalCount": 2,
"page": 1,
"pageSize": 10
"nextCursorToken": null
}
```

Expand Down Expand Up @@ -203,10 +227,13 @@ GET /api/users?filter=status:eq:active&page=1&pageSize=20&includeCount=false
**Response:**
```json
{
"data": [ ... ],
"totalCount": null,
"resultCount": null,
"page": 1,
"pageSize": 20
"pageSize": 20,
"aggregates": null,
"data": [ "..." ],
"nextCursorToken": null
}
```

Expand Down
31 changes: 24 additions & 7 deletions docs/examples/real-world.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,14 @@ GET /api/orders?filter=createdAt:between:2024-01-01,2024-12-31,status:in:pending
**Response:**
```json
{
"totalCount": 143,
"resultCount": 143,
"page": 1,
"pageSize": 25,
"totalPages": 6,
"hasNextPage": true,
"hasPreviousPage": false,
"aggregates": null,
"data": [
{
"id": 1001,
Expand All @@ -72,9 +80,7 @@ GET /api/orders?filter=createdAt:between:2024-01-01,2024-12-31,status:in:pending
"customer": { "name": "Bob Smith" }
}
],
"totalCount": 143,
"page": 1,
"pageSize": 25
"nextCursorToken": null
}
```

Expand Down Expand Up @@ -177,6 +183,14 @@ GET /api/products?filter=category:eq:electronics,price:lte:500
**Response:**
```json
{
"totalCount": 28,
"resultCount": 28,
"page": 1,
"pageSize": 10,
"totalPages": 3,
"hasNextPage": true,
"hasPreviousPage": false,
"aggregates": null,
"data": [
{
"id": 5,
Expand All @@ -196,9 +210,7 @@ GET /api/products?filter=category:eq:electronics,price:lte:500
"reviews": []
}
],
"totalCount": 28,
"page": 1,
"pageSize": 10
"nextCursorToken": null
}
```

Expand Down Expand Up @@ -239,12 +251,17 @@ GET /api/reports/revenue?filter=createdAt:between:2024-01-01,2024-12-31,status:e
**Response:**
```json
{
"totalCount": 3,
"resultCount": 3,
"page": 1,
"pageSize": 20,
"aggregates": null,
"data": [
{ "region": "North America", "allCount": 512, "amountSum": 128000.00, "amountAvg": 250.00 },
{ "region": "Europe", "allCount": 380, "amountSum": 95000.00, "amountAvg": 250.00 },
{ "region": "Asia Pacific", "allCount": 210, "amountSum": 52500.00, "amountAvg": 250.00 }
],
"totalCount": 3
"nextCursorToken": null
}
```

Expand Down
Loading
Loading