I’m using nhibernate envers to audit my data / save previous versions.
What I’d like to do is store previous versions against the parent entity.
Something like this:
public abstract class BookBase
{
public virtual int ID { get; set; }
public virtual string Name { get; set; }
public virtual string Author { get; set; }
}
public class Book : BookBase
{
public virtual ICollection<BookRevision> PreviousVersions { get; set; }
}
public class BookRevision : BookBase
{
public virtual int VersionNumber { get; set; }
public virtual DateTime VersionTimeStamp { get; set; }
}
Is that possible with envers nhibernate (using fluent nHibernate for mappings)
What would my envers config need to look like?
What would my mappings need to look like?
Envers handles auditing for you, you don’t have to define your own auditing types in your domain model.
Define (and map it as normal) your entity
If you want to do auditing on Book modifications, configure Envers like this