Lyo.EntityReference.Models
1.0.6
See the version list below for details.
dotnet add package Lyo.EntityReference.Models --version 1.0.6
NuGet\Install-Package Lyo.EntityReference.Models -Version 1.0.6
<PackageReference Include="Lyo.EntityReference.Models" Version="1.0.6" />
<PackageVersion Include="Lyo.EntityReference.Models" Version="1.0.6" />
<PackageReference Include="Lyo.EntityReference.Models" />
paket add Lyo.EntityReference.Models --version 1.0.6
#r "nuget: Lyo.EntityReference.Models, 1.0.6"
#:package Lyo.EntityReference.Models@1.0.6
#addin nuget:?package=Lyo.EntityReference.Models&version=1.0.6
#tool nuget:?package=Lyo.EntityReference.Models&version=1.0.6
Lyo.EntityReference.Models
Typed pair of logical entity kind (EntityType) and identifier string (EntityId), plus helpers for composite keys, JSON, opaque tokens, validation, and domain row shapes. No database or EF dependency.
Examples
Quick start
using System.Text.Json;
using Lyo.EntityReference.Models;
// From CLR type + Guid key (logical type from attribute or FullName)
var r = EntityRef.For<MyAggregate>(aggregate.Id);
// From entity instance + collection expression keys
var rEntity = EntityRef.For(person, p => [p.Id]);
// Logical type name only
var typeName = EntityRef.LogicalTypeName<MyAggregate>();
// Explicit type + id
var r2 = EntityRef.ForKey("Comic.Issue", issueId.ToString());
// JSON: register converter once
var options = new JsonSerializerOptions();
options.Converters.Add(new EntityRefJsonConverter());
JsonSerializer.Serialize(r, options); // {"entityType":"...","entityId":"..."}
// Relation endpoints (For = subject, From = actor)
var endpoints = EntityRelationBuilder.For<Volume>(volumeId).From<User>(userId);
EntityRelationValidation.RequireSubjectActor(endpoints.Subject, endpoints.Actor);
// Import provenance (owner id assigned on persist)
var source = EntitySourceRecord.From<EndatoPsPerson>(externalId, DateTime.UtcNow);
EntitySourceValidation.RequireSource(source);
// Map EntityRef to persisted string columns (Guid ids become "d290f1ee-6c54-4b01-90e6-d701748f0851")
var subjectId = EntityRefPersistedGuid.PersistedEntityId(subjectRef);
Concepts
EntityRef. Immutable value (readonly record struct) used at API boundaries. Constructors validate non-whitespace type and id.- Stable type names. Decorate CLR types with
[EntityRefLogicalType("MyModule.Widget")]so persistedEntityTypedoes not depend onType.FullName. - Composite ids. Multiple key segments are sorted lexically and joined via
EntityRefCompositeEncodingso literal:inside a segment stays unambiguous. - Relation vs source. Two persistence shapes:
- Relations (favorite, note, comment, …). Subject + actor endpoints. Domain types use
SubjectEntityType/ActorEntityId. PostgreSQL columns remainfor_entity_*/from_entity_*. - Source links (
*_source). External import provenance only:source_entity_type/source_entity_id+imported_at. Owner identity lives on the parent aggregate (for exampleperson_id), not in EntityReference. - String persistence. Endpoint and source ids are nullable varchar at the DB. Stores and validation helpers enforce required values per use case. Callers still pass
EntityRefat API boundaries. UseEntityRefPersistedGuid.PersistedEntityId()(orRequirePersistedGuidwhen comparing to rowGuidprimary keys) whenEntityIdis a single GUID string. EntityRelationRow. Abstract domain mirror of a tenant-scoped relation row (subject/actor, visibility, soft-delete, metadata). Endpoint properties arestring?, aligned with persisted columns.EntitySourceRecord. Provenance shape:(EntityRef Source, DateTime ImportedAt). UseEntitySourceRecord.From(source, importedAt)at import. The owning aggregate id is set when persisting child*_sourcerows.IEntitySourceDerived. Aggregates imported from external sources carry optionalEntitySourceRecord? SourceandLocallyModifiedAtwhen local edits diverge from the external source.
Debugging
EntityRef, EntityRelationRow, EntityRefOptions, and EntityRefActionContext use [DebuggerDisplay(...)] for compact watches. Several types override ToString() for readable logs, distinct from ToOpaqueToken() on EntityRef.
Dependencies
Generated from ProjectReference / PackageReference (same model as docs/Lyo.ProjectGraph.html).
Lyo.Common(direct, lyo)Lyo.Exceptions(direct, lyo)System.Text.Json10.0.5(direct, microsoft, netstandard2.0)Microsoft.Extensions.Logging.Abstractions10.0.5(transitive, microsoft)System.Memory4.6.3(transitive, microsoft, netstandard2.0)
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. 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 was computed. 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. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
| .NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- Lyo.Common (>= 1.0.6)
- Lyo.Exceptions (>= 1.0.6)
- System.Text.Json (>= 10.0.5)
-
net10.0
- Lyo.Common (>= 1.0.6)
- Lyo.Exceptions (>= 1.0.6)
NuGet packages (24)
Showing the top 5 NuGet packages that depend on Lyo.EntityReference.Models:
| Package | Downloads |
|---|---|
|
Lyo.EntityReference.Postgres
Entity Framework Core base entity, configuration, and store helpers for canonical entity-ref rows on PostgreSQL. |
|
|
Lyo.Config
Typed configuration definitions and per-entity bindings using flexible EntityRef references and JSON-backed values. |
|
|
Lyo.Geolocation.Models
Geolocation models and data structures for the Lyo library suite. |
|
|
Lyo.Audit
Audit trail library with AuditChange (entity change tracking) and AuditEvent (events to log). AuditChange has type assembly full name, old values, and changed properties. AuditEvent has event type, timestamp, actor, message, and metadata. Includes IAuditRecorder for pluggable storage. |
|
|
Lyo.Geolocation
Geolocation utilities and services for the Lyo library suite. |
GitHub repositories
This package is not used by any popular GitHub repositories.