Table of Contents

Interface IRelationshipMetadata

Namespace
NextORM.Core
Assembly
nextorm.core.dll

Read-only metadata for a declared navigation relationship between two entity types. A relationship is declared explicitly (fluent HasMany/HasOne or RelationshipAttribute); the core does not infer relationships from conventions.

public interface IRelationshipMetadata
Extension Methods

Remarks

Both sides of a relationship are declared independently and symmetrically; the inverse is not inferred. When both sides are declared and agree on the foreign key and the participating types, Inverse points at the other side's metadata; otherwise it is null. A key-only declaration (HasMany/HasOne taking explicit foreign- and principal-key selectors, for an entity without a navigation property) has a null Navigation.

Properties

DeclaringType

The entity type that declares Navigation.

Type DeclaringType { get; }

Property Value

Type

ForeignKey

The ordered foreign-key components on the dependent side, resolved from that type's entity metadata. The list is never empty when the relationship resolves successfully. Order is part of the contract: it is the declaration/selector order of the components, and the component at position i pairs positionally with PrincipalKey's component at i.

IReadOnlyList<IPropertyMetadata> ForeignKey { get; }

Property Value

IReadOnlyList<IPropertyMetadata>

Exceptions

NotSupportedException

A foreign-key component is not mapped on the dependent type, the component lists are empty or duplicated, have different arities, or a nullable-unwrapped component type does not match PrincipalKey at the same position.

Inverse

The inverse relationship declared on RelatedType, or null when the other side has not been declared or does not converge on the same foreign key.

IRelationshipMetadata? Inverse { get; }

Property Value

IRelationshipMetadata

IsCollection

Whether Navigation is a collection (OneToMany). false when there is no navigation.

bool IsCollection { get; }

Property Value

bool

Junction

The junction descriptor of a ManyToMany relationship, or null for every other kind and for a many-to-many relationship that was declared without a junction. The default implementation returns null so existing external implementations keep compiling.

RelationshipJunctionMetadata? Junction { get; }

Property Value

RelationshipJunctionMetadata

Kind

The cardinality of the relationship.

RelationshipKind Kind { get; }

Property Value

RelationshipKind

Navigation

The navigation property on DeclaringType; a collection for OneToMany, a reference otherwise. null for a key-only relationship declared without a navigation property.

PropertyInfo? Navigation { get; }

Property Value

PropertyInfo

PrincipalKey

The ordered principal-key components of the principal side, resolved from that type's entity metadata: the properties flagged with IsKey via [Key], .Key(), or the Id/<TypeName>Id convention, or the explicitly selected components. Order is part of the contract: it is the selector order for an explicit principal key, or the full key in entity-metadata property order for a default principal key; the component at position i pairs positionally with ForeignKey's component at i. A default principal key is never reduced to its first component.

IReadOnlyList<IPropertyMetadata> PrincipalKey { get; }

Property Value

IReadOnlyList<IPropertyMetadata>

Exceptions

NotSupportedException

The principal type declares no key, a component is not mapped, the component lists are empty or duplicated, have different arities, or a nullable-unwrapped component type does not match ForeignKey at the same position.

RelatedType

The entity type the navigation points to.

Type RelatedType { get; }

Property Value

Type