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());

Answers


You don't need to specify anything about those fields. Just:

Mapper.CreateMap<DomainModel, ViewModel>();

If the CreatedOn and ModifiedOn properties don't exist on your view model when mapping between DM and VM they will be simply ignored.


Need Your Help

How to loop through a few variable IDs?

jquery function table checkbox

Please refer my Fiddle here. I have a table with dynamic rows, each containing a checkbox with variable ID id="monitor_'+rowID+'"where rowID is a global variable declared without keyword var inside