0

I have the following classes:

public class Entity 
{
}

public class Company : Entity
{
}

public class Person : Entity
{
}

public class SomeOther
{
   public Entity A { get; set; }
}

And the following DTOs:

public class EntityDTO
{
}

public class SomeOtherDTO
{
   public EntityDTO A { get; set; }
}

And the following Mappings:

CreateMap<Person, EntityDTO>();
CreateMap<Company, EntityDTO>();

Is there any way of doing CreateMap<Entity, EntityDTO>() and tell Automapper to use the relevant mapping based on the derived type?

0 Answers0