MementoEntity and MementoEntityCollection
When we spoke about the Change Tracking Service we introduced a code snippet such as the following:
In order to leverage the full power of the memento services we can change the above snippet as follows:
Calling memento.Undo()
will trigger the undo of the last operation, we can call undo until CanUndo
is true
rolling back change by change, that in the above sample will revert back the LastName
property value to its default value.
The requirement to achieve the above is that the Person
class is a Radical memento entity:
As we can see from the above snippet all we need to do is to create a class the inherits from the MementoEntity
base class and declare all the properties we want to track as Radical properties.
A similar approach can be used to keep track of items in a collection:
Calling memento.Undo()
will trigger the undo of the last operation that in the above sample will revert the collection status removing the last added value.
We can do more:
Last updated