2
를 수신 나는 다음과 같은 매핑이하십시오 PlaylistDto 객체와 뒷면에 재생 목록 개체를 변환는 AutoMapper 업데이트 지금 매핑되지 않은 속성 예외
Mapper.CreateMap<Playlist, PlaylistDto>()
.ReverseMap()
.ForMember(playlist => playlist.Folder,
opt => opt.MapFrom(playlistDto => folderDao.Get(playlistDto.FolderId)));
합니다. AutoMapper를 업데이트하기 전에는 훌륭하게 작동하는 것처럼 보였습니다. 내가 전화를 지금
:
Mapper.AssertConfigurationIsValid();
나는 참조 :
[DataContract]
public class PlaylistDto
{
[DataMember(Name = "id")]
public Guid Id { get; set; }
[DataMember(Name = "title")]
public string Title { get; set; }
[DataMember(Name = "folderId")]
public Guid FolderId { get; set; }
[DataMember(Name = "items")]
public List<PlaylistItemDto> Items { get; set; }
[DataMember(Name = "sequence")]
public int Sequence { get; set; }
public PlaylistDto()
{
Id = Guid.Empty;
Title = string.Empty;
Items = new List<PlaylistItemDto>();
}
public static PlaylistDto Create(Playlist playlist)
{
PlaylistDto playlistDto = Mapper.Map<Playlist, PlaylistDto>(playlist);
return playlistDto;
}
}
public class Playlist : AbstractShareableDomainEntity
{
public virtual Folder Folder { get; set; }
// Use interfaces so NHibernate can inject with its own collection implementation.
public virtual ICollection<PlaylistItem> Items { get; set; }
public virtual int Sequence { get; set; }
public Playlist()
{
Id = Guid.Empty;
Title = string.Empty;
Items = new List<PlaylistItem>();
Sequence = -1;
}
}
왜 자동에서 FolderId을 AutoMapper 수없는 유도하는 것입니다 : 같은
Unmapped members were found. Review the types and members below.
Add a custom mapping expression, ignore, add a custom resolver, or modify the source/destination type
=====================================================
PlaylistDto -> Playlist (Source member list)
Streamus.Dto.PlaylistDto -> Streamus.Domain.Playlist (Source member list)
-----------------------------------------------------
FolderId
재생 목록 및 PlaylistDto 모습 업데이트 후 폴더?
대답은 명시 적으로 내 매핑을 선언했다Mapper.CreateMap<Playlist, PlaylistDto>()
.ForMember(playlist => playlist.FolderId,
opt => opt.MapFrom(playlistDto => playlistDto.Folder.Id))
.ReverseMap()
.ForMember(playlist => playlist.Folder,
opt => opt.MapFrom(playlistDto => folderDao.Get(playlistDto.FolderId)));
명시 적으로 매핑 할 때'FolderId 아직도 내가 FolderId에 명시 적으로 매핑을 정의하려고해도 불평 것을
주 '.. 정확히 같은 오류입니까? –
예, 명시 적으로 매핑 할 때 동일한 오류가 발생합니다. 이상하지, 그렇지? –
이것은 ASP.NET 응용 프로그램입니까? Application_Start/Global.asax에서 AutoMapper를 초기화한다고 가정합니다. 완전히 로컬 웹 서버를 다시 시작했거나 Visual Studio를 닫고 다시여시겠습니까? –