Class EntityReferenceProperty<T>
- Namespace
- The.Relationships
- Assembly
- Instagile.dll
One-to-one foreign key
public sealed class EntityReferenceProperty<T> : EntityReferenceProperty, IOwnedValue<IEntity?>, IValue<IEntity?>, IOwnedValue<T?>, IValue<T?>, INotifyValueChanged, IProperty, IOwned, IHasChanges, ILazy<T?>, ILazy where T : IEntity<T>
Type Parameters
T
- Inheritance
-
EntityReferenceProperty<T>
- Implements
-
IOwnedValue<T>IValue<T>ILazy<T>
- Inherited Members
Constructors
EntityReferenceProperty(RelationshipInfo, EntityKernel)
public EntityReferenceProperty(RelationshipInfo metadata, EntityKernel parent)
Parameters
metadataRelationshipInfoparentEntityKernel
Properties
HasValue
Gets a value indicating whether the reference has a non-null value. Does not require or force the property to be present.
[MemberNotNullWhen(true, new string[] { "Value", "ID" })]
public override bool HasValue { get; }
Property Value
ID
The related entity's ID, which may be the pending known ID of a set-by-ID insert, the known ID of an unloaded entity, or the actual ID of a loaded entity.
public Guid? ID { get; }
Property Value
- Guid?
Remarks
Redeclared so that HasValue can target it for control-flow analysis.
OriginalValue
public T? OriginalValue { get; }
Property Value
- T
Value
read/write underlying data
public T? Value { get; set; }
Property Value
- T
Methods
AsLoaded()
Asserts that the property object is loaded and returns it; never performs I/O.
public T? AsLoaded()
Returns
- T
Exceptions
- InvalidOperationException
Thrown if the property or any reference along the path to it is unloaded.
AsUnloaded()
public IEntityQuery<T> AsUnloaded()
Returns
- IEntityQuery<T>
Clone(IEntityContext?)
public EntityReferenceProperty<T> Clone(IEntityContext? context = null)
Parameters
contextIEntityContext
Returns
Get()
public T? Get()
Returns
- T
GetAsync(CancellationToken)
[Obsolete("Replaced by LoadAsync()")]
public Task<T?> GetAsync(CancellationToken cancellationToken = default)
Parameters
cancellationTokenCancellationToken
Returns
- Task<T>
GetCachedAsync(RequestOptions?, CancellationToken)
[Obsolete("Replaced by LoadCachedAsync()")]
public Task<T?> GetCachedAsync(RequestOptions? options = null, CancellationToken cancellationToken = default)
Parameters
optionsRequestOptionscancellationTokenCancellationToken
Returns
- Task<T>
GetRelatedEntityCachedAsync(Guid, RelationshipPath[], RequestOptions, CancellationToken?)
protected override Task<IEntity?> GetRelatedEntityCachedAsync(Guid id, RelationshipPath[] includes, RequestOptions options, CancellationToken? cancellationToken)
Parameters
idGuidincludesRelationshipPath[]optionsRequestOptionscancellationTokenCancellationToken?
Returns
LoadAsync(CancellationToken?)
Loads the property object in at most one read batch.
public Task<T?> LoadAsync(CancellationToken? cancellationToken = null)
Parameters
cancellationTokenCancellationToken?
Returns
- Task<T>
LoadAsync(RelationshipPath[], CancellationToken?)
Loads the property object and related data in at most one read batch.
public Task<T?> LoadAsync(RelationshipPath[] includes, CancellationToken? cancellationToken = null)
Parameters
includesRelationshipPath[]cancellationTokenCancellationToken?
Returns
- Task<T>
LoadCachedAsync(RequestOptions?, CancellationToken?)
Asynchronously loads the referenced entity using the query cache. Returns immediately with stale data if available, with background refresh for stale entries.
public Task<T?> LoadCachedAsync(RequestOptions? options = null, CancellationToken? cancellationToken = null)
Parameters
optionsRequestOptionsCache request options controlling freshness requirements and priority.
cancellationTokenCancellationToken?Cancellation token for the operation.
Returns
- Task<T>
The referenced entity, or null if the reference has no value.
LoadCachedAsync(RequestOptions?, RelationshipPath[], CancellationToken?)
As LoadCachedAsync(RequestOptions?, CancellationToken?), also loading includes from the referenced entity.
public Task<T?> LoadCachedAsync(RequestOptions? options, RelationshipPath[] includes, CancellationToken? cancellationToken = null)
Parameters
optionsRequestOptionsincludesRelationshipPath[]cancellationTokenCancellationToken?
Returns
- Task<T>
QueryRelatedEntityAsync(Guid, RelationshipPath[], CancellationToken?)
protected override Task<IEntity> QueryRelatedEntityAsync(Guid id, RelationshipPath[] includes, CancellationToken? cancellationToken)
Parameters
idGuidincludesRelationshipPath[]cancellationTokenCancellationToken?
Returns
SetFrom(EntityReferenceBase<T>?)
Assigns from a path type:
- an unbound loaded reference copies its value
- a unloaded bound reference copies its ID without loading
- null clears
public void SetFrom(EntityReferenceBase<T>? value)
Parameters
valueEntityReferenceBase<T>