How to use ForMember in automapper 4.2 with MapperConfiguration?

989 Views Asked by At

I followed this to preserve the static feel of earlier automapper API but now i am not able to understand how should I use ForMember api, to map specific members. Any help is appreciated. Thanks.

1

There are 1 best solutions below

0
On

ForMember method stills the same:

var config = new MapperConfiguration(cfg => {
    cfg.CreateMap<Source, Dest>().ForMember(dest => dest.Id, opt => opt.Ignore());
});

var mapper = config.CreateMapper();
var destination = mapper.Map<Source, Dest>(new Source());