С помощью automapper пытался делать маппинг модели БД на модель Dto
internal class DepartamentStructService : IDepartamentStructService
{
private IUnitOfWork Database { get; set; }
private IAutoMapper AutoMapper { get; set; }
public DepartamentStructService(IUnitOfWork database, IAutoMapper autoMapper)
{
Database = database;
AutoMapper = autoMapper;
}
public IEnumerable<DepartamentStructDto> GetDepartamentStructAll() => AutoMapper.Projection<IEnumerable<DEPARTMENTSTRUCT>, IEnumerable<DepartamentStructDto>>(Database.DepartamentsStruct.GetAll());
public void Dispose() => Database.Dispose();
}
И получаю вот такую ошибку System.TypeLoadException: "Отсутствует реализация метода "GetEnumerator", уже все перепробывал не знаю что делать, подскажите! За интерфейсом IAutoMapper стоит класс
internal class AutoMapperCollection : IAutoMapper
{
public TDestination Projection<TSource, TDestination>(TSource source)
where TSource : class
where TDestination : class
{
var mapper = new MapperConfiguration(cfg => cfg.CreateMap<TSource, TDestination>()).CreateMapper();
return mapper.Map<TSource, TDestination>(source);
}
}