I've the abstract class AbsProduct
public abstract class AbsProduct
{
[Key]
public int ID { get; set; }
public int Price { get; set; }
public int Category { get; set; }
public string Name { get; set; }
public abstract double Accept(IProductVisitor visitor);
}
and the ProductDTO:
public class ProductDTO
{
public int ID { get; set; }
public int Price { get; set; }
public int Category { get; set; }
public string Name { get; set; }
}
My configuration is
AutoMapper.Mapper.Initialize(config =>
{
config.CreateMap<AbsProduct, ProductDTO>();
config.CreateMap<ProductDTO, AbsProduct>();
});
The problem is when I try to map ProductDTO to AbsProduct:
var product = AutoMapper.Mapper.Map<ProductDTO, AbsProduct>(productDTO);
AutoMapper is returning null, but the source(productDTO) isn't null.