Path: redb/redb.Examples/Models/ExampleModels.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/ExampleModels.cs ---- using redb.Core.Models.Entities; using redb.Core.Attributes; namespace redb.Examples.Models; /// /// Tag with priority for categorization. /// public class Tag { public string Name { get; set; } = string.Empty; public int Priority { get; set; } public string? Description { get; set; } } /// /// Project metrics for analytics. /// [RedbScheme("ProjectMetrics")] public class ProjectMetricsProps { public long ProjectId { get; set; } public long? TasksCompleted { get; set; } public long? TasksTotal { get; set; } public long? BugsFixed { get; set; } public double? Budget { get; set; } public long? TeamSize { get; set; } public Tag[]? Tags { get; set; } public string[]? Technologies { get; set; } } /// /// Address with city, street and building details. /// public class Address { public string City { get; set; } = string.Empty; public string Street { get; set; } = string.Empty; public BuildingInfo? Building { get; set; } } /// /// Building information with floor and amenities. /// public class BuildingInfo { public int Floor { get; set; } public string Name { get; set; } = string.Empty; public string[]? Amenities { get; set; } public int[]? AccessCodes { get; set; } public string[]? ParkingSpots { get; set; } public int[]? ElevatorFloors { get; set; } } /// /// Contact detail key-value pair. /// public class ContactDetail { public string Label { get; set; } = string.Empty; public string Value { get; set; } = string.Empty; } /// /// Contact information (email, phone, etc). /// public class Contact { public string Type { get; set; } = string.Empty; public string Value { get; set; } = string.Empty; public bool IsVerified { get; set; } public int[]? NotificationHours { get; set; } public ContactDetail[]? Metadata { get; set; } } /// /// Department info with tags, metrics and nested budget data. /// public class Department { public string Name { get; set; } = string.Empty; public int HeadCount { get; set; } public string[] Projects { get; set; } = []; public Tag[] Leaders { get; set; } = []; public Dictionary? BudgetByYear { get; set; } } /// /// Employee props - main model for examples. /// Demonstrates all supported types: /// - Simple types (int, string, DateTime, long, decimal) /// - Arrays (string[], int[]) /// - Business classes (Address with nested BuildingInfo) /// - Array of business classes (Contact[]) /// - RedbObject references (CurrentProject, PastProjects[]) /// - Dictionary types (various key and value types) /// [RedbScheme("Employee")] public class EmployeeProps { // Basic info public string FirstName { get; set; } = string.Empty; public string LastName { get; set; } = string.Empty; public int Age { get; set; } public DateTime HireDate { get; set; } public string Position { get; set; } = string.Empty; public decimal Salary { get; set; } public string Department { get; set; } = string.Empty; public string? EmployeeCode { get; set; } // Skills and certifications (arrays) public string[]? Skills { get; set; } public int[]? SkillLevels { get; set; } public string[]? Certifications { get; set; } public int[]? CertificationYears { get; set; } // Addresses (business classes) public Address? HomeAddress { get; set; } public Address? WorkAddress { get; set; } public Address? EmergencyAddress { get; set; } // Contacts (array of business classes) public Contact[]? Contacts { get; set; } // Project references (RedbObject) public RedbObject? CurrentProject { get; set; } public RedbObject[]? PastProjects { get; set; } // Phone directory: extension -> phone number public Dictionary? PhoneDirectory { get; set; } // Office locations by city public Dictionary? OfficeLocations { get; set; } // Bonus history by year public Dictionary? BonusByYear { get; set; } // Department details with complex nested data (Pro) public Dictionary? DepartmentHistory { get; set; } // Composite key: (year, quarter) -> performance score (Pro) public Dictionary<(int Year, string Quarter), string>? PerformanceReviews { get; set; } // Project metrics by code (Pro) public Dictionary>? ProjectMetrics { get; set; } } /// /// Department props for tree examples (corporate hierarchy). /// Used with TreeRedbObject for organizational structure. /// Similar to CategoryTestProps in ConsoleTest. /// [RedbScheme("Department")] public class DepartmentProps { /// Department name (e.g. "IT Department Moscow"). public string Name { get; set; } = string.Empty; /// Description (e.g. "Software development team"). public string Description { get; set; } = string.Empty; /// Is department active? public bool IsActive { get; set; } = true; /// Budget in USD. public decimal Budget { get; set; } /// Department code (e.g. "IT-MSK-DEV"). public string Code { get; set; } = string.Empty; } /// /// City props for list examples (linked objects). /// Used as target object for RedbListItem.Object reference. /// [RedbScheme("City")] public class CityProps { /// City name. public string Name { get; set; } = string.Empty; /// Population count. public int Population { get; set; } /// Region or district. public string Region { get; set; } = string.Empty; /// Is capital city? public bool IsCapital { get; set; } /// GPS coordinates [lat, lon]. public double[] Coordinates { get; set; } = []; } /// /// Person props demonstrating ListItem fields. /// Shows single ListItem and List of ListItems usage. /// [RedbScheme("Person")] public class PersonProps { /// Person name. public string Name { get; set; } = string.Empty; /// Age in years. public int Age { get; set; } /// Email address. public string Email { get; set; } = string.Empty; /// Single ListItem field (e.g. status from dictionary). public RedbListItem? Status { get; set; } /// Array of ListItems (e.g. roles from dictionary). public List? Roles { get; set; } } /// /// Product with a unique business key (V4 [RedbUnique]): the SKU is unique per scheme, /// enforced by the database over the hash of the canonical value. Used by E003. /// public class ProductProps { /// Unique business key. NULL never participates in uniqueness. [RedbUnique] public string? Sku { get; set; } /// Display name (not unique). public string Title { get; set; } = string.Empty; /// Price in USD. public decimal Price { get; set; } }