I have classes which have the usual CreatedDate, CreatedById, EditedDate, EditedById and etc. fields on which I ignore when mapping from Domain models -> Entity models (they are populated later by the database).
My mappings are now littered with mapping ignore looking a bit like
CreateMap<UpdateProvider, ProviderInstance>()
.ForMember(e => e.Id, opt => opt.Ignore())
.ForMember(e => e.CreatedDate, opt => opt.Ignore())
.ForMember(e => e.CreatedById, opt => opt.Ignore())
.ForMember(e => e.EditedDate, opt => opt.Ignore())
.ForMember(e => e.EditedById, opt => opt.Ignore())
.ForMember(e => e.ArchivedDate, opt => opt.Ignore())
.ForMember(e => e.ArchivedById, opt => opt.Ignore());
Can I centralize this in a single method to adhere to the DRY principle. If it helps each of these fields have interfaces called IIdentifiable, ICreateable, IEditable, IArchiveable.
I was hoping to just create an extension method of something like .IgnoreDbGeneratedFields<TDestination>()