AutoMapper Ignore () not working when using ForSourceMember?

I am trying to ignore a property from a source type. I defined the mapping as follows:

var map = AutoMapper.Mapper.CreateMap<Article, IArticle>(); map.ForSourceMember(s => s.DateCreated, opt => opt.Ignore()); map.ForSourceMember(s => s.DateUpdated, opt => opt.Ignore()); 

When I call the Map function,

 AutoMapper.Mapper.Map(article, articlePoco); 

destination properties are still updated. I am using the latest stable version downloaded from NuGet.

Any ideas why this is not working?

I found a similar question to this, but no answer. [question]: Ignore AutoMapper () not working?

+6
source share
1 answer

Change the mapping to use ForMember:

 map.ForMember(s => s.DateCreated, opt => opt.Ignore()); map.ForMember(s => s.DateUpdated, opt => opt.Ignore()); 
+6
source

Source: https://habr.com/ru/post/958987/


All Articles