Cześć, mam problem ze zmapowaniem dwóch obiektów.
public IEnumerable<DropdownModel> GetAuthorsDropdown()
{
var config = new MapperConfiguration(cfg =>
{
cfg.CreateMap<Author, DropdownModel>()
.ForMember(dto => dto.Id, opt => opt.MapFrom(x => x.Id))
.ForMember(dto => dto.DisplayName, opt => opt.MapFrom(x => (x.FirstName + " " + x.SecondName)));
});
var authors = _authorRepository.GetAuthors();
IEnumerable<DropdownModel> authorsDropdown = _mapper.Map<IEnumerable<Author>, IEnumerable<DropdownModel>>(authors); //tutaj występuje exception
return authorsDropdown;
}
Poniżej exception, który otrzymuję:
"Error mapping types. Mapping types: IEnumerable
1 -> IEnumerable
1\r\nSystem.Collections.Generic.IEnumerable1[[DataAccessLogic.Entities.Author, DataAccessLogic, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]] -> System.Collections.Generic.IEnumerable
1Application.Models.DropdownModel, Application, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"} AutoMapper.AutoMapperMappingException