shwetaOnStack
shwetaOnStack

Reputation: 594

How to use ForMember in automapper 4.2 with MapperConfiguration?

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.

Upvotes: 0

Views: 987

Answers (1)

Ilya Chumakov
Ilya Chumakov

Reputation: 25039

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

Upvotes: 1

Related Questions