Reputation: 3810
public class ProfileA : ProfileB
{
CreateMap<Source, Destination>(d => d.Age, opt => opt.UseValue(14));
}
public class ProfileB : Profile
{
public ProfileB()
{
CreateMap<Source, Destination>(d => d.Name, opt => opt.UseValue("qqq"));
}
}
Even though the maps are on same source and destination type I want the separation by creating a base Profile then inheriting and creating more specific Profiles. But as with above code only ProfileA
's mappers will be applied.
How can I achieve such feat using AutoMapper or is it even considered a good practice for AutoMapper?
Upvotes: 0
Views: 1577
Reputation: 3516
Having the same map in different profiles is an anti-pattern and is not allowed by default. There is only one map and overriding it in this way only makes things difficult. See this. It can be overridden.
Upvotes: 1