Compare two objects of the same entity type and return the differences. Differences for create, update and delete are handled.
There are different versions of actions with method signatures to suit different scenarios.
Translations are available for English, Spanish, French, Japanese, Malay, Portuguese, Russian and Chinese. Please let me know if there is a translation you would like. Translations files are also welcome!
The simplest usage is to just call CompareObjectsToText, or CompareObjectsToHtml. These will compare the objects and return Text or HTML identifying the difference between the passed in objects.
For the creation of an object, pass in NullObject() for the OldObject. For the deletion of an object, pass in NullObject() for the NewObject.
The CompareObjects action returns the differences in a structure that can be used programmatically.
The ComparisonResultToText action converts the comparison returned by CompareObjects to text. It is intened this is used for human readable audit records.
The ComparisonResultToHtml action converts the comparison returned by CompareObjects to HTML. It is intended this is used for human readable audit records. Values are HTML encoded to guard against injection attacks.
The "Config" actions provide additional configuration options. Site properties are also available to override default configuration settings for NullPlaceholder, CurrencySymbol, DecimalSeparator and GroupSeparator. FormatOverrides allow a .NET format specifier to control how an attribute is formatted in the output.
Users of the library can also write their own formatting actions and just use the CompareObjects action.
Note on foreign keys:
Values for foreign keys use the "Label" attribute of the foreign entity as well as displaying the id. If the label attribute of a foreign entity is a foreign key, the library will display the value for the second foreign entity, if a Label attribute is defined for it. The id value for the foreign key entity is also displayed.