Table of Contents

Class EntityBase<TProperties, TReport>

Namespace
The.Entities
Assembly
Instagile.dll

Base class for all entities, wrapping an EntityKernel to provide core properties and lifecycle management.

public abstract class EntityBase<TProperties, TReport> : IEntity, IHasChanges where TProperties : IEntityProperties

Type Parameters

TProperties
TReport
Inheritance
EntityBase<TProperties, TReport>
Implements
Inherited Members
Extension Methods

Constructors

EntityBase(EntityPropertiesFactory<TProperties, TReport>)

[Obsolete("not safe; does not set _Kernel until Init() is later called!")]
protected EntityBase(EntityPropertiesFactory<TProperties, TReport> propsFactory)

Parameters

propsFactory EntityPropertiesFactory<TProperties, TReport>

EntityBase(IEntityInfo, IEntityContext, IEntityInitialiser, EntityPropertiesFactory<TProperties, TReport>)

protected EntityBase(IEntityInfo metadata, IEntityContext context, IEntityInitialiser initialiser, EntityPropertiesFactory<TProperties, TReport> propsFactory)

Parameters

metadata IEntityInfo
context IEntityContext
initialiser IEntityInitialiser
propsFactory EntityPropertiesFactory<TProperties, TReport>

Properties

Context

An entity's unit of work for saving. Entities in a graph must be in the same context.

[JsonIgnore]
public IEntityContext Context { get; }

Property Value

IEntityContext

ID

Unique identifier of this entity

public Guid ID { get; }

Property Value

Guid

Remarks

useful in generic queries

Kernel

The entity's dynamic kernel.

[JsonIgnore]
public EntityKernel Kernel { get; }

Property Value

EntityKernel

Logger

protected ILogger Logger { get; }

Property Value

ILogger

Properties

The entity's dynamic propertyobjects.

[JsonIgnore]
public TProperties Properties { get; }

Property Value

TProperties

Services

protected IServices Services { get; }

Property Value

IServices

Text

Textual description of the entity

public string Text { get; }

Property Value

string

Remarks

useful in generic queries

report

Null-safe stringified version of the entity for reports and descriptions.

[JsonIgnore]
public TReport report { get; }

Property Value

TReport

Methods

Delete()

Mark the entity for deletion when next saved

[Obsolete("Non-async delete is deprecated because it tends to leave entities in an unsaveable state.")]
public void Delete()

DeleteAndCascadeAsync(CancellationToken?)

deletes an entity as well as its owned (Value) entities, removing it from unowned (Lookup) relationships

public Task DeleteAndCascadeAsync(CancellationToken? cancellationToken = null)

Parameters

cancellationToken CancellationToken?

Returns

Task

DeleteAndPruneAsync(CancellationToken?)

Mark the entity for deletion when next saved, removing it from all relationships first

public Task DeleteAndPruneAsync(CancellationToken? cancellationToken = null)

Parameters

cancellationToken CancellationToken?

Returns

Task

HasChanges()

true if the current value differs from its original

public bool HasChanges()

Returns

bool

Init(IEntityInfo, IEntityContext, IEntityInitialiser)

protected void Init(IEntityInfo metadata, IEntityContext context, IEntityInitialiser initialiser)

Parameters

metadata IEntityInfo
context IEntityContext
initialiser IEntityInitialiser

IsCalculated()

protected virtual bool IsCalculated()

Returns

bool

MarkUnchanged()

update original data so that it's no longer considered changed

public void MarkUnchanged()

NeedsSave()

true if the value has non-derived changes, ones made deliberately by a user or business logic

public bool NeedsSave()

Returns

bool

OnCreated()

protected virtual void OnCreated()

OnLoaded()

protected virtual void OnLoaded()

OnSaved()

protected virtual void OnSaved()

OnSavedAsync()

protected virtual Task OnSavedAsync()

Returns

Task

OnSaving()

protected virtual void OnSaving()

OnSavingAsync()

protected virtual Task OnSavingAsync()

Returns

Task

SaveAsync(CancellationToken?)

Save the graph rooted at this entity to the data store

public Task SaveAsync(CancellationToken? cancellationToken = null)

Parameters

cancellationToken CancellationToken?

Returns

Task

ToString()

Returns a string that represents the current object.

public override sealed string ToString()

Returns

string

A string that represents the current object.