mirror of
https://github.com/clockworklabs/SpacetimeDB.git
synced 2026-05-06 07:26:43 -04:00
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>
This commit is contained in:
@@ -402,13 +402,27 @@ for (const user of ctx.db.user.age.filter(
|
||||
<TabItem value="csharp" label="C#">
|
||||
|
||||
```csharp
|
||||
// Find users aged 18 or older
|
||||
foreach (var user in ctx.Db.User.Age.Filter(new Bound<byte>.Inclusive(18), null))
|
||||
// Find users aged 18 to 65 (inclusive)
|
||||
foreach (var user in ctx.Db.User.Age.Filter(new Bound<byte>(18, 65)))
|
||||
{
|
||||
Log.Info($"{user.Name} is {user.Age}");
|
||||
}
|
||||
|
||||
// Find users aged 18 or older (inclusive, unbounded above)
|
||||
foreach (var user in ctx.Db.User.Age.Filter(new Bound<byte>(18, byte.MaxValue)))
|
||||
{
|
||||
Log.Info($"{user.Name} is an adult");
|
||||
}
|
||||
|
||||
// Find users younger than 18 (unbounded below, to 17 inclusive)
|
||||
foreach (var user in ctx.Db.User.Age.Filter(new Bound<byte>(byte.MinValue, 17)))
|
||||
{
|
||||
Log.Info($"{user.Name} is a minor");
|
||||
}
|
||||
```
|
||||
|
||||
You can also use the implicit tuple conversion, like `ctx.Db.User.Age.Filter((18, byte.MaxValue))`, which is functionally identical.
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="rust" label="Rust">
|
||||
|
||||
|
||||
Reference in New Issue
Block a user