Skip to content

Commit 9eb64ef

Browse files
committed
Start adding some recipes
1 parent c7dda76 commit 9eb64ef

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

README.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,12 @@ A typical set of operators is supported:
132132
* Indexers `a[b]` and accessors `a.b`
133133
* Wildcard indexing - `a[?]` any, and `a[*]` all
134134
* Conditional `if a then b else c` (all branches required)
135+
136+
Comparision operators that act on text all accept an optional post-fix `ci` modifier to select case-insensitive comparisons:
137+
138+
```
139+
User.Name like 'n%' ci
140+
```
135141

136142
### Functions
137143

@@ -161,6 +167,32 @@ calling a function will be undefined if:
161167
| `TagOf(o)` | Returns the `TypeTag` field of a captured object (i.e. where `TypeOf(x)` is `'object'`). |
162168
| `TypeOf(x)` | Returns a string describing the type of expression `x`: a .NET type name if `x` is scalar and non-null, or, `'array'`, `'object'`, `'dictionary'`, `'null'`, or `'undefined'`. |
163169

170+
Functions that compare text accept an optional post-fix `ci` modifier to select case-insensitive comparisons:
171+
172+
```
173+
StartsWith(User.Name, 'n') ci
174+
```
175+
176+
## Recipes
177+
178+
**Trim down `SourceContext` to a type name only:**
179+
180+
```
181+
coalesce(Substring(SourceContext, LastIndexOf(SourceContext, '.') + 1), SourceContext, '<no source>')
182+
```
183+
184+
**Access a property with a non-identifier name:**
185+
186+
```
187+
@p['some name']
188+
```
189+
190+
**Access a property with inconsistent casing:**
191+
192+
```
193+
ElementAt(@p, 'someName') ci
194+
```
195+
164196
## Working with the raw API
165197

166198
The package provides the class `SerilogExpression` in the `Serilog.Expressions` namespace

0 commit comments

Comments
 (0)