Skip to content
Arnel Robles edited this page Sep 29, 2026 · 2 revisions

Package 11: Mapsicle.Audit

See what a mapping did, or what it would change.

using Mapsicle.Audit;

var result = user.MapWithAudit<UserDto>();
UserDto dto = result.GetValueOrThrow();
IEnumerable<string> missed = result.Audit.UnmappedProperties;   // destination members nothing filled

// Map, then compare against what you already have
var detected = request.MapAndDetectChanges(existingDto);
if (detected.HasChanges)
{
    foreach (var change in detected.Changes)
    {
        Console.WriteLine($"{change.PropertyName}: {change.OldValue} to {change.NewValue}");
    }
}

// Compare any two instances of one type
List<PropertyChange> diff = before.Diff(after);

Diff compares a collection property element by element, so two lists with the same contents in the same order are not a change. Any other property is compared with Equals, which for a nested class without its own Equals means by reference: two equal Address instances count as a change.


Clone this wiki locally