Search code examples
c#nhibernatenhibernate-envers

Create revision when a property of a list element is changed


Let's assume I have the following entities:

public class Group
{
    public IList<Item> Items { get; set; } 
}

public class Item
{
    public Group Group { get; set; } 

    public string Name { get; set; } 
}

Now I want Envers to create a revision for Group when the Name property of Item has changed. The revision_on_collection_change property just works if I change the collection (as the name suggests ;-) itself.

Is there a possibilty to setup Envers to 'connect' the parent entity with properties of its child element properties?


Solution

  • Short answer: No.

    Longer answer: Depending on your use case there are alternatives that might suit your needs. Either make sure that your Group entity will be modified when one of its Items are or include revisions with modified Items when querying for a Group (the latter would probably need your relation to be bidirectional though).