Automapper: bidirectional mapping with ReverseMap() and ForMember()

ReverseMap returns an IMappingExpression that represents the reversal of the mapping. Once you call, it subsequent calls will be for configuring the reversal of the map.

Here’s an example:

Mapper.CreateMap<CartItemDto, CartItemModel>()
      .ForMember(dest => dest.ExtendedCost, opt => opt.Ignore())
      .ReverseMap()
          .ForMember(dest => dest.Pricing, opt => opt.Ignore())

This will ignore the Pricing field in the reverse direction.

Leave a Comment

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