Given the class
public abstract class Entity<T> : IEntity<T>, IAuditableEntity,ISoftDeletable where T : struct, IComparable
{
public virtual T Id { get; set; }
public virtual DateTime CreatedDate { get; set; }
public virtual string CreatedBy { get; set; }
public virtual DateTime UpdatedDate { get; set; }
public virtual string UpdatedBy { get; set; }
public virtual bool Deleted { get; set; }
}
from which several types are derived, how one can, using automapper transform them into something whose base class would look like
public abstract class ViewModelEntity<T> : Entity<T>, where T : struct, IComparable
{
public virtual T Id { get; protected set; }
public virtual DateTime CreatedDate { get; protected set; }
public virtual string CreatedBy { get; protected set; }
public virtual DateTime UpdatedDate { get; protected set; }
public virtual string UpdatedBy { get; protected set; }
public virtual bool Deleted { get; protected set; }
}
meaning, i want my viewmodels to disallow the setters for those base properties, but not any other property the entity might have.
The relevance of this is that those properties will be automatically set at the data layer/repository level and the UI coder can only consume them