// ========================================================
namespace Kerosene.ORM.Maps
{
using Kerosene.ORM.Core;
using System;
// ====================================================
/// <summary>
/// Enumerates the possible values of the current state of a meta entity.
/// </summary>
public enum KMetaState
{
Collected, // The entity has been collected.
Detached, // The entity is not attached to any map.
Ready, // The entity is ready (has been retrieved from, or persisted to, a database, or attached to a map).
ToInsert, // The entity is to be inserted.
ToDelete, // The entity is to be deleted.
ToUpdate, // the entity is to be updated.
}
// ====================================================
/// <summary>
/// Represents an abstract entity managed by a meta map.
/// </summary>
public interface IKMetaEntity
{
/// <summary>
/// The real entity this instance refers to. This reference can be null if the underlying entity has been
/// collected.
/// </summary>
object Entity { get; }
/// <summary>
/// The map that manages the underlying real entity. This property might be null if that entity is not yet
/// attached to any map, for instance when is has not been yet retrieved from or persisted to a database,
/// when it has been deleted or detached, or when the underlying entity has been collected.
/// </summary>
IKMetaMap MetaMap { get; }
/// <summary>
/// Gets the current state of this instance.
/// </summary>
KMetaState State { get; }
/// <summary>
/// Gets the object describing the pending operation on the entity, or null if there is any.
/// </summary>
IKMetaOperation MetaOperation { get; }
/// <summary>
/// Gets the record associated with this instance.
/// </summary>
IKRecord Record { get; }
}
}
// ========================================================