How to configure Conditional Mapping in AutoMapper?

Try this

 Mapper.CreateMap<Source, Target>()
        .ForMember(dest => dest.Value, 
                   opt => opt.MapFrom
                   (src => src.Value1.StartsWith("A") ? src.Value1 : src.Value2));

Condition option is used to add conditions to properties that must be met before that property will be mapped and MapFrom option is used to perform custom source/destination member mappings.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)