Skip to content

Commit af29a78

Browse files
rekhoffjdetter
andauthored
Updated Query with Indexes to be code-accurate (#4165)
# Description of Changes Implements the fix for #4130 by updating docs with accurate usage instructions for Query with Indexes in C#. # API and ABI breaking changes Docs only, no API or ABI changes # Expected complexity level and risk 1 # Testing - [X] Tested code snippets through addition of regression tests in #4123 Co-authored-by: John Detter <4099508+jdetter@users.noreply.github.com>
1 parent bf0c3b6 commit af29a78

1 file changed

Lines changed: 16 additions & 2 deletions

File tree

docs/docs/00200-core-concepts/00300-tables/00300-indexes.md

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -402,13 +402,27 @@ for (const user of ctx.db.user.age.filter(
402402
<TabItem value="csharp" label="C#">
403403

404404
```csharp
405-
// Find users aged 18 or older
406-
foreach (var user in ctx.Db.User.Age.Filter(new Bound<byte>.Inclusive(18), null))
405+
// Find users aged 18 to 65 (inclusive)
406+
foreach (var user in ctx.Db.User.Age.Filter(new Bound<byte>(18, 65)))
407+
{
408+
Log.Info($"{user.Name} is {user.Age}");
409+
}
410+
411+
// Find users aged 18 or older (inclusive, unbounded above)
412+
foreach (var user in ctx.Db.User.Age.Filter(new Bound<byte>(18, byte.MaxValue)))
407413
{
408414
Log.Info($"{user.Name} is an adult");
409415
}
416+
417+
// Find users younger than 18 (unbounded below, to 17 inclusive)
418+
foreach (var user in ctx.Db.User.Age.Filter(new Bound<byte>(byte.MinValue, 17)))
419+
{
420+
Log.Info($"{user.Name} is a minor");
421+
}
410422
```
411423

424+
You can also use the implicit tuple conversion, like `ctx.Db.User.Age.Filter((18, byte.MaxValue))`, which is functionally identical.
425+
412426
</TabItem>
413427
<TabItem value="rust" label="Rust">
414428

0 commit comments

Comments
 (0)