Class E004_SubtreeAndElementKeys

Assembly: redb.Examples.dll

Unique keys beyond a root scalar (V4). Props are stored flat, one row per value, and the
storage already maintains a canonical hash for every nested class and collection - so
[RedbUnique] reaches four more shapes with the same database-enforced index:

A scalar INSIDE a nested class - a lambda path (d => d.Identity!.Serial) is the key.
A whole SUBTREE - the content of a nested class, in canonical form, is the key.
A whole COLLECTION - the ordered list is the key; the same numbers in another order differ.
ELEMENTS of a collection with a scope: UniqueScope.Collection forbids duplicates
inside one object's collection, UniqueScope.Scheme makes every element value unique
across all objects of the scheme (and probeable by GetByUniqueAsync).

Plus [RedbTags]: a free-form marker written to the scheme and structure metadata for
applications and extensions to read back.

[ExampleMeta("E004", "Unique Keys - nested, subtree and element keys, [RedbTags]", "CRUD", ExampleTier.Free, 4, new string[] { "Unique", "RedbUnique", "UniqueScope", "RedbTags", "GetByUniqueAsync" }, RelatedApis = new string[] { "IRedbService.GetByUniqueAsync", "IRedbService.SaveAsync", "IRedbService.GetSchemeByTypeAsync" })]
public class E004_SubtreeAndElementKeys : ExampleBase

Inheritance

Object→ExampleBase→E004_SubtreeAndElementKeys

Inherited Members

Methods

RunAsync(IRedbService)

Run the example and return result.

public override Task<ExampleResult> RunAsync(IRedbService redb)