1

From startup class of my Asp.net core webAPI, I map my DTO class to Entity class. In order to use Partial update of my entity I want to map the destination property only if the source property is not null. Following code sample works as expected:

`AutoMapper.Mapper.Initialize(opt =>
        {
            [...]
            opt.CreateMap<DtoClass, EntityClass>()
                .ForMember(dest => dest.Name,
                           o => o.Condition(src => src.Name != null))
                .ForMember(dest => dest.Email, 
                           o => o.Condition(src => src.Email != null));
        });`

I have many other properties and I am wondering if there is a way to group all those ForMember statements (with ForAllMembers or another method that would help). I am quiet new using Automapper, so any help will be appreciated.

Jzrzmy
  • 301
  • 1
  • 2
  • 10

0 Answers0