I have inherited my base "User" class to create role specific types.
eg...
public class Business : User{
public string BusinessName;
}
I've done a similar thing for my View Models, starting with a basic "UserModel" and inheriting that to include role specific functionality.
public class BusinessModel : UserModel{
[Required()]
public string BusinessName;
}
When I use Automapper to map changes to my BusinessModel back to my Business object, it doesn't include any changes to the inherited fields.
//create map between model and business object
Mapper.CreateMap<BusinessModel, Business>();
//load the relevant business
var business = GetCurrentBusiness();
//map the values across
Mapper.Map<BusinessModel, Business>(model, business);
Changes to any fields on the "Business" it's self are present. However any changes to fields inherited from User aren't.
Is Automapper just unable to map inherited types like this? Or am I missing something?