Search code examples
c#nhibernatenhibernate-envers

Query revisions where properties were modified and select a flag if property was modified


I have the following class

public class Product
{
    public virtual int Id { get; set; }
    public virtual double Price { get; set; }
    public virtual string Description { get; set; }
}

The audit table looks like this

CREATE TABLE Product_AUD (
    Id integer not null,
    REV integer not null,
    Price float,
    Price_MOD bit,
    Description varchar(255),
    Description_MOD bit,
    REVTYPE tinyint not null,
    primary key (id, REV)
);

My query looks like this

var revisionEntityInfos =
    Session.Auditer().CreateQuery()
           .ForHistoryOf<Product, DefaultRevisionEntity>()
           .Add(AuditEntity.Id().Eq(ProductId))
           .Add(AuditEntity.Or(AuditEntity.Property("Description").HasChanged(),
                               AuditEntity.Property("Price").HasChanged()))
           .Results();

So far this works and returns an IEnumerable<Product, DefaultRevisionEntity>. I get all revisions where either the property Description, the property Price or both have changed. The information of RevisionId and RevisionDate is included.

But I also want to see which properties have changed for each revision, since I want to display this to the user. So basically I want to have the HasChanged flag in the result. Is this possible?


Solution

  • No, it's currently not supported.

    Feel free to add a JIRA ticket about this.