Reading about ReversMap() , I can’t understand the difference between ForMember and ForPath . The functionality that ForPath performs on this page I usually do with ForMember .
Here is an example where I configure two-way mapping and everything works correctly:
public class Customer { public string Surname { get; set; } public string Name { get; set; } public int Age { get; set; } } public class CustomerDto { public string CustomerName { get; set; } public int Age { get; set; } } static void Main(string[] args) { Mapper.Initialize(cfg => { cfg.CreateMap<Customer, CustomerDto>() .ForMember(dist => dist.CustomerName, opt => opt.MapFrom(src => $"{src.Surname} {src.Name}")) .ReverseMap() .ForMember(dist => dist.Surname, opt => opt.MapFrom(src => src.CustomerName.Split(' ')[0])) .ForMember(dist => dist.Name, opt => opt.MapFrom(src => src.CustomerName.Split(' ')[1])); }); // код с маппингом Customer -> CustomerDto //... // // код с маппингом CustomerDto -> Customer var customerDto = new CustomerDto { CustomerName = "Shakhabov Adam", Age = 31 }; var newCustomer = Mapper.Map<CustomerDto, Customer>(customerDto); } Question
Methods ForMember and ForPath in something duplicate functionality? Or what can not be done with ForMember , but with ForPath ?