using LiteDB; using System; using System.Collections.Generic; using System.ComponentModel; using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; using System.Data.Entity; using System.Linq; using System.Text; using System.Threading.Tasks; using Tango.BL.Serialization; using Tango.Core; using Tango.Core.Json; namespace Tango.BL { /// /// Represents an observable database entity. /// public interface IObservableEntity : INotifyDataErrorInfo, IParameterized , ISerializableEntity { /// /// Occurs after this observable has been modified and saved by this entity context or another. /// event EventHandler Modified; /// /// Gets or sets the entity identifier. /// [Column("ID")] [DatabaseGeneratedAttribute(DatabaseGeneratedOption.Identity)] [ParameterIgnore] Int32 ID { get; set; } /// /// Gets or sets the entity unique identifier. /// [Key] [Column("GUID")] [ParameterIgnore] [BsonId] String Guid { get; set; } /// /// Gets or sets the entity last updated data and time. /// [Column("LAST_UPDATED")] [ParameterIgnore] DateTime LastUpdated { get; set; } /// /// Saves the changes on this entity to database. /// void Save(ObservablesContext context); /// /// Attaches this observable to the proper DbSet. /// void Attach(ObservablesContext context); /// /// Detaches this observable from the proper DbSet. /// void Detach(ObservablesContext context); /// /// Saves the changes on this entity to database asynchronously. /// /// Task SaveAsync(ObservablesContext context); /// /// Deletes this entity using an SQL statement which will cause the database delete cascade effect. /// Task DeleteCascadeAsync(ObservablesContext context); /// /// Gets the database set containing this entity. /// /// /// The context. /// DbSet GetDbSet(ObservablesContext context) where T : class, IObservableEntity; /// /// Raises the event. /// void RaiseModified(ObservablesContext context, IObservableEntity source, IObservableEntity target); /// /// Removes this entity and all dependent entities from the specified db context. /// /// The context. void Delete(ObservablesContext context); /// /// Called when before entity is saved by the context. /// void OnBeforeSave(); } }