CoreEx.RefData
4.0.0-preview-1
dotnet add package CoreEx.RefData --version 4.0.0-preview-1
NuGet\Install-Package CoreEx.RefData -Version 4.0.0-preview-1
<PackageReference Include="CoreEx.RefData" Version="4.0.0-preview-1" />
<PackageVersion Include="CoreEx.RefData" Version="4.0.0-preview-1" />
<PackageReference Include="CoreEx.RefData" />
paket add CoreEx.RefData --version 4.0.0-preview-1
#r "nuget: CoreEx.RefData, 4.0.0-preview-1"
#:package CoreEx.RefData@4.0.0-preview-1
#addin nuget:?package=CoreEx.RefData&version=4.0.0-preview-1&prerelease
#tool nuget:?package=CoreEx.RefData&version=4.0.0-preview-1&prerelease
CoreEx.RefData
Provides the CoreEx reference data framework: typed base classes for reference data items and collections, a hybrid-cache-backed orchestrator, contextual date-validity checking, and a code-serialization collection.
Overview
CoreEx.RefData implements the domain concept of reference data — lookup tables (e.g. Status, Country, Currency) that are read frequently and change rarely. Items carry an Id, a Code, Text, Description, SortOrder, IsActive, and optional StartsOn/EndsOn date range, all of which participate in validity checking via ReferenceDataContext.
Two concrete base classes cover the most common identity types: ReferenceData<TSelf> (string Id) and ReferenceData<TId, TSelf> (arbitrary TId). Each exposes static TryGetById and TryGetByCode helpers that delegate to the ambient ReferenceDataOrchestrator registered in the DI container. Collections are thread-safe dictionaries keyed by both Id and Code; GetItems returns a stable, sorted IEnumerable by ReferenceDataSortOrder.
ReferenceDataHybridCache implements IReferenceDataCache on top of IHybridCache, using per-type semaphores to ensure that only one thread performs the expensive load while others wait, then everyone benefits from the cached result. ReferenceDataCodeCollection<TRef> solves the serialization problem: a property declared as a list of codes is stored as List<string?> on the wire but exposes ICollection<TRef> at the domain level.
Key capabilities
- 📚 Typed reference data base classes:
ReferenceData<TSelf>(string Id) andReferenceData<TId, TSelf>(typed Id) provideId,Code,Text,Description,SortOrder,IsActive,StartsOn/EndsOn, mapping support, andThrowIfInactive/ThrowIfInvalidguards. - 📋 Thread-safe collections:
ReferenceDataCollection<TRef>andReferenceDataCollection<TId, TRef>index items by bothIdandCode(case-insensitive by default) and exposeGetItems(sortOrder, activeOnly, isValid)for filtered, ordered enumeration. - 🔄 Hybrid-cache backing:
ReferenceDataHybridCacheimplementsIReferenceDataCacheviaIHybridCache; per-type semaphores prevent thundering-herd on cold start and support configurable entry options per item type viaOnCreateCacheEntry. - 📅 Contextual date validity:
ReferenceDataContextsupplies the reference date used to evaluateStartsOn/EndsOnon every item; the date can be set globally or overridden per type, defaulting toRuntime.UtcNow. - 🌐 Localised text and description:
TextandDescriptionare resolved throughLTexton every get, enabling locale-specific display strings without changing the domain model. - 🏷 Code-serialization collection:
ReferenceDataCodeCollection<TRef>stores codes asList<string?>for wire serialization while presenting anICollection<TRef>interface backed by the live orchestrator lookups. - 🔧 DI and health-check helpers:
AddReferenceDataOrchestratorand relatedIServiceCollectionextensions register the orchestrator and cache;ReferenceDataOrchestratorHealthCheckexposes a health-check endpoint reporting all registered reference data types.
Key types
| Type | Description |
|---|---|
ReferenceData<TSelf> |
Abstract reference data base with string Id; provides static TryGetById/TryGetByCode, implicit/explicit string cast operators, and IComparable<TSelf> by code. |
ReferenceData<TId, TSelf> |
Abstract reference data base with arbitrary typed TId; same feature set as ReferenceData<TSelf> but with both Id and Code lookups. |
ReferenceDataCollection<TRef> |
Thread-safe IReferenceDataCollection with string Id; indexes by Id and Code, default sort by ReferenceDataSortOrder.SortOrder. |
ReferenceDataCollection<TId, TRef> |
Thread-safe IReferenceDataCollection with typed TId; otherwise identical to the string variant. |
ReferenceDataCodeCollection<TRef> |
Serializes a reference data relationship as a List<string?> of codes on the wire while presenting ICollection<TRef> at the domain level. |
ReferenceDataHybridCache |
IReferenceDataCache implementation backed by IHybridCache; per-type semaphores enforce single-loader semantics on cache miss; supports per-type entry-option customisation via OnCreateCacheEntry. |
ReferenceDataContext |
Supplies the contextual date used to evaluate StartsOn/EndsOn validity; settable globally or per reference data type. |
ReferenceDataSortOrder |
Enum: SortOrder, Id, Code, Text; controls the ordering returned by GetItems. |
Namespaces
| Namespace | Description | Documentation |
|---|---|---|
CoreEx.RefData.Abstractions |
Core abstract implementations: ReferenceDataCore<TId> and ReferenceDataCollectionCore<TId, TRef> providing the full identity, validity, mapping, and collection infrastructure. |
📖 README |
CoreEx.RefData.HealthChecks |
ReferenceDataOrchestratorHealthCheck — reports all registered reference data types to the ASP.NET Core health-check endpoint. |
📖 README |
Related namespaces
CoreEx- DefinesIReferenceData,IReferenceDataCollection,IReferenceDataCache,ReferenceDataOrchestrator, andIHybridCacheconsumed throughout.CoreEx.Caching.FusionCache-FusionHybridCacheis the recommendedIHybridCacheimplementation for backingReferenceDataHybridCachein production.
AI Usage Guide
An AGENTS.md file is included with this package. AI coding assistants (GitHub Copilot, Claude, Cursor, etc.) that support workspace-injected package documentation will automatically surface concise usage guidance, code examples, and Do Not rules for this package without requiring a local CoreEx checkout.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- CoreEx (>= 4.0.0-preview-1)
- Microsoft.Extensions.Diagnostics.HealthChecks (>= 10.0.3)
-
net8.0
- CoreEx (>= 4.0.0-preview-1)
- Microsoft.Extensions.Diagnostics.HealthChecks (>= 8.0.24)
-
net9.0
- CoreEx (>= 4.0.0-preview-1)
- Microsoft.Extensions.Diagnostics.HealthChecks (>= 9.0.13)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 4.0.0-preview-1 | 50 | 6/20/2026 |