0

I.e. I have the following map class:

public class AutoMapperAddress : AutoMapper.Profile
{
    public AutoMapperAddress()
    {
        CreateMap<AddressDto, ViewModels.AddressElementAPI>();
    }
}

then I should use it in other places, i.e:

public class AutoMapperLocation : AutoMapper.Profile
{
    public AutoMapperLocation()
    {
        // location mappers here
        // I need the same Address mapping as AutoMapperAddress has
    }
}

public class AutoMapperCarrier : AutoMapper.Profile
{
    public AutoMapperCarrier ()
    {
        // carrier mappers here
        // I need the same Address mapping as AutoMapperAddress has
    }
}

How to do it?

ADDED:

I tried to solve it during create mapper object:

        mapper = (new MapperConfiguration(cfg => {
            cfg.AddProfile<Models.AutoMapperRules.AutoMapperLocation>();
            cfg.AddProfile<Models.AutoMapperRules.AutoMapperAddress>();
            }
        )).CreateMapper();

but I want to incapsulate it inside AutoMapperLocation, because no sense to have AutoMapperLocation without AutoMapperAddress

Oleg Sh
  • 8,496
  • 17
  • 89
  • 159

0 Answers0