ignore Mapping from DomainModel to ViewModel
I have 2 fields in DomainModel (CreatedOn,ModifiedOn) which are not in my ViewModel. How can I put ignore on Source fields when mapping from DomainModel to ViewModel. Please fix below code.
Mapper.CreateMap<DomainModel, ViewModel>() .ForMember(d => d.CreatedOn, opt => opt.Ignore()) .ForMember(d => d.ModifiedOn, opt => opt.Ignore());
You don't need to specify anything about those fields. Just:
If the CreatedOn and ModifiedOn properties don't exist on your view model when mapping between DM and VM they will be simply ignored.