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: docs/pages/guide/queryBuilder.md
+96Lines changed: 96 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -11,6 +11,8 @@ The `QueryBuilder` class is useful when you want to manually build your query or
11
11
| UseCustomMapper | Accepts a GridifyMapper to use in build methods |
12
12
| UseEmptyMapper | Sets up an empty GridifyMapper without auto-generated mappings |
13
13
| AddMap | Adds a single map to the existing mapper |
14
+
| AddCompositeMap | Adds a composite map that searches across multiple properties with OR logic |
15
+
| AddNestedMapper | Adds a nested mapper to reuse mappings from nested object types |
14
16
| RemoveMap | Removes a single map from the existing mapper |
15
17
| ConfigureDefaultMapper | Configures the default mapper when UseCustomMapper method is not used |
16
18
| IsValid | Validates Condition, OrderBy, Query, and Mapper; returns a boolean |
@@ -31,3 +33,97 @@ var builder = new QueryBuilder<Person>()
31
33
32
34
varquery=builder.Build(persons);
33
35
```
36
+
37
+
## AddNestedMapper
38
+
39
+
The `AddNestedMapper` method in `QueryBuilder<T>` allows you to reuse mapper configurations for nested objects when building queries dynamically. This mirrors the functionality available in `GridifyMapper<T>`, enabling DRY (Don't Repeat Yourself) mapper composition in query builders.
40
+
41
+
::: tip Related Documentation
42
+
For detailed information about nested mappers and their benefits, see the [AddNestedMapper documentation in GridifyMapper guide](./gridifyMapper.md#addnestedmapper).
43
+
:::
44
+
45
+
### Basic Usage Examples
46
+
47
+
#### Example 1: Reusing Address Mapper Without Prefix
48
+
49
+
```csharp
50
+
// Define a reusable address mapper
51
+
varaddressMapper=newGridifyMapper<Address>()
52
+
.AddMap("city", x=>x.City)
53
+
.AddMap("country", x=>x.Country);
54
+
55
+
// Use in QueryBuilder - merges directly
56
+
varbuilder=newQueryBuilder<User>()
57
+
.AddMap("email", x=>x.Email)
58
+
.AddNestedMapper(x=>x.Address, addressMapper)
59
+
.AddCondition("city=London")
60
+
.AddOrderBy("email");
61
+
62
+
varresult=builder.Build(users.AsQueryable());
63
+
// Supports: "city=London", "country=UK"
64
+
```
65
+
66
+
#### Example 2: Reusing Address Mapper With Prefix
0 commit comments