I've got problem with Automapper. My mapping call looks like:
var dataContracts = MapperManager.Mapper.Map<List<Employee>, List<EmployeeDTO>>(entities.ToList());
Entity is IQueryable<Employee>
In my Mapper helper class I Have:
public class MapperManager
{
public static MapperConfiguration MapperConfiguration { get; set; }
private static IMapper _mapper { get; set; }
public static IMapper Mapper
{
get
{
if (_mapper == null) {
_mapper = MapperConfiguration.CreateMapper();
}
return _mapper;
}
}
public static void RegisterMappinngs()
{
MapperConfiguration = new MapperConfiguration(cfg =>
{
...
cfg.CreateMap<Employee, EmployeeDTO>().MaxDepth(5);
...
}
}
}
RegisterMappings is called once on AppStartup in Global.asax and after that I've Exception in Map operation:
var dataContracts = MapperManager.Mapper.Map<List<Employee>, List<EmployeeDTO>>(entities.ToList());
Error mapping types.
Mapping types: List`1 -> List`1 System.Collections.Generic.List`1[[NAMESPACE.Employee, ASSEMBLY, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]] -> System.Collections.Generic.List`1[[NAMESPACE2.EmployeeDTO, ASSEMBLY2, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]
Anyone can provide any idea what I'm doing wrong?
Best regards
MapperConfiguration.AssertConfigurationIsValid()
? – Dean Goodman