Skip to main content
  1. Tags/

Automapper

Implementing AutoMapper for DTO Mapping with Audit Details

Deep Dive .NET · Dec 1, 2024 · 6 min read
Early versions of the Contact Management Application had the same four lines at the end of every create and update method: set CreatedBy, set CreatedOn (or their Updated* twins), then save. Copy-pasted audit code gets forgotten just often enough to make the audit columns untrustworthy, and an audit column you can’t trust is worse than none. Moving that logic into AutoMapper profiles fixed it in one place.
Implementing AutoMapper for DTO Mapping with Audit Details