Path: redb/redb.Examples/Models/DeviceModels.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Examples/Models/DeviceModels.cs
----
using redb.Core.Attributes;
namespace redb.Examples.Models;
///
/// Device with every V4 key shape beyond the plain scalar one (E004):
/// - a key on a scalar INSIDE a nested class ();
/// - a key on a whole SUBTREE - the content of a nested class or a collection is the key;
/// - ELEMENT keys on collections, scoped to one collection or to the whole scheme;
/// - a free-form [RedbTags] marker on the scheme and on a structure.
///
[RedbTags("examples,e004")]
public class DeviceProps
{
public string? Title { get; set; }
/// Nested class whose Serial is a key: unique per scheme, like a root key.
public DeviceIdentity? Identity { get; set; }
/// Subtree key: two devices cannot carry the same configuration content.
[RedbUnique]
public DeviceConfig? Config { get; set; }
/// Subtree key on a collection: the ordered list of ports is the key.
[RedbUnique]
public List? Ports { get; set; }
/// Element keys, Collection scope: no duplicate label inside ONE device.
[RedbUnique(Scope = UniqueScope.Collection)]
public List? Labels { get; set; }
/// Element keys, Scheme scope: a MAC address belongs to one device in the whole scheme.
[RedbUnique(Scope = UniqueScope.Scheme)]
[RedbTags("network")]
public List? MacAddresses { get; set; }
}
public class DeviceIdentity
{
[RedbUnique]
public string? Serial { get; set; }
public string? Vendor { get; set; }
}
public class DeviceConfig
{
public string? Region { get; set; }
public long? Tier { get; set; }
}