AutoMapper: manually set property
automapper, c#
Solution
Use `BeforeMap` method to set property value before mapping process:
Mapper.CreateMap<Source, Destination>()
.BeforeMap((s, d) => d.IsPropertyChangedEnabled = false );
Problem
I am using AutoMapper to map from flat DataObjects to fat BusinessObjects and vice versa. I noticed that mapping from DataObjects to BusinessObjects takes extra time because of change notification of the BusinessObjects (implements INotifyPropertyChanged with custom validation, etc). Because I normally don't need change notification during mapping, I'd like to turn it off. So I added a property "IsPropertyChangedEnabled". If this property is set to false, no NotifyPropertyChanged event is not raised and time is saved. Question: Can I tell AutoMapper to set this property to false at the very beginning of the mapping process? If so, how? Thank you!