Class RedbUniqueAttribute
Declares a Props property a unique key within its scheme: no two objects of the scheme may
hold the same value in it. Enforced by the database — a unique index over
_values (_id_structure, _unique), where _unique is the 128-bit hash of the
value's canonical form () — and surfaced as
.
Allowed on: a scalar property — string, integers, Guid, bool,
double/float, decimal, DateTime/DateTimeOffset/
DateOnly, byte[] and their nullable forms — of the Props class or of a nested
class reached without crossing a collection (S2); and on a whole nested class, array or
dictionary property, where the key is the SUBTREE content (S1). Not on enums (stored as
list-item references, no canonical value form), single RedbObject references, or
members of collection ELEMENTS — element rows share one structure across every element of
every object. Scheme synchronisation rejects a misplaced attribute with
.
null never participates: any number of objects may leave the key empty.
The value is compared exactly, after Unicode NFC normalisation for strings: no trimming, no
case folding. A key is a notion of the application; an application that wants
case-insensitive or trimmed keys normalises them before saving — the same contract as a unique
index in any database, and what EF Core and Hibernate do.
Putting the attribute on a property of a scheme that already has data recomputes the column
for every existing object at the next synchronisation and reports duplicates
() instead of failing start-up: duplicate rows stay
outside the index until they are resolved.
[AttributeUsage(AttributeTargets.Property, AllowMultiple = false, Inherited = true)]
public sealed class RedbUniqueAttribute : Attribute
Inheritance
Properties
Scope
On a COLLECTION property switches from the subtree-content key (the default) to
public UniqueScope Scope { get; set; }