- /// <summary>
- /// List of possible state for an entity.
- /// </summary>
- ///实体状态定义
- public enum EntityState
- {
- /// <summary>
- /// Entity is unchanged
- /// </summary>
- Unchanged=0,
- /// <summary>
- /// Entity is new
- /// </summary>
- Added=1,
- /// <summary>
- /// Entity has been modified
- /// </summary>
- Changed=2,
- /// <summary>
- /// Entity has been deleted
- /// </summary>
- Deleted=3
- }
- /// <summary>
- /// The interface that each business object of the model implements.
- /// </summary>
- public interface IEntity
- {
- /// <summary>
- /// The name of the underlying database table.表名
- /// </summary>
- string TableName { get;}
- /// <summary>
- /// Indicates if the object has been modified from its original state.
- /// </summary>
- ///<value>True if object has been modified from its original state; otherwise False;</value>
- ///实体改变时为TRUE,否则为假
- bool IsDirty {get;}
- /// <summary>
- /// Indicates if the object is new.
- /// </summary>
- ///<value>True if objectis new; otherwise False;</value>
- ///实体为新建时为TRUE
- bool IsNew {get;}
- /// <summary>
- /// True if object has been marked as deleted. ReadOnly.
- /// </summary>
- ///实体标记为DELETED时为TRUE
- bool IsDeleted {get;}
- /// <summary>
- /// Indicates if the object is in a valid state
- /// </summary>
- /// <value>True if object is valid; otherwise False.</value>
- ///校验有效时为TRUE
- bool IsValid { get;}
- /// <summary>
- /// Returns one of EntityState enum values - intended to replace IsNew, IsDirty, IsDeleted.
- /// </summary>
- //返回实体状态
- EntityState EntityState {get;}
- /// <summary>
- /// Accepts the changes made to this object by setting each flags to false.
- /// </summary>
- ///当手动实现保存方法后,通过acceptchange方法来修改对象的属性,状态改为未修改,还将副本清除
- void AcceptChanges();
- /// <summary>
- /// Marks entity to be deleted.
- /// </summary>
- ///标记实体为删除
- void MarkToDelete();
- /// <summary>
- /// Gets or sets the parent collection.
- /// </summary>
- /// <value>The parent collection.</value>
- ///取父实体
- object ParentCollection{get;set;}
- /// <summary>
- /// The name of the underlying database table's columns.
- /// </summary>
- /// <value>A string array that holds the columns names.</value>
- ///取列名数组
- string[] TableColumns {get;}
- /// <summary>
- /// Gets or sets the object that contains supplemental data about this object.
- /// </summary>
- /// <value>Object</value>
- ///实体的摘要内容
- object Tag { get;set;}
- /// <summary>
- /// Event to indicate that a property has changed.
- /// </summary>
- ///实体属性改变事件
- event PropertyChangedEventHandler PropertyChanged;
- /// <summary>
- /// Determines whether this entity is being tracked.
- /// </summary>
- bool IsEntityTracked { get; set; }
- ///<summary>
- /// The tracking key used to with the <see cref="EntityLocator" />
- ///</summary>
- string EntityTrackingKey { get; set; }
- }
- /// <summary>
- /// Interface that TList and every entity implements to support
- /// cloning of an object tree.
- /// </summary>
- ///克隆扩展接口
- public interface ICloneableEx
- {
- ///<summary>
- /// The tracking key used to with the <see cref="EntityLocator" />
- ///</summary>
- ///<param name="existingCopies">A list containing references to all objects already copied.</param>
- object Clone(IDictionary existingCopies);
- }