검색을 많이했는데 Automapper로지도를 수집하는 방법을 잘 모릅니다.오토 맵퍼로 컬렉션 매핑?
을 감안할 때 :
Public Class PostSummaryDTO
Public Property PostId As Integer
Public Property PostGuid As Guid
Public Property PostTitle As String
Public Property PostSummary As String
Public Property PostDateCreated As DateTime
Public Property PostIsPublished As Boolean
Public Property PostText As String
Public Property PostCategory As ICollection(Of be_Categories)
Public Property PostTag As ICollection(Of be_PostTag)
Public Author As String
End Class
및
Public Class be_PostsViewModel
Public Property Id As Integer
Property Author As String
<DisplayName("Title")> <Required(ErrorMessage:="Your post must have a title")>
Public Property PostTitle As String
<DisplayName("My Snarky Text")> Public Property PostSummary As String
<DisplayName("Post")> Public Property PostText As String
<UIHint("DateCreated")> <DisplayName("Date Created")> Property PostDateCreated
As DateTime?
<DisplayName("Publish")> Public Property PostIsPublished As Boolean
Public Property PostGuid As Guid
Public Property BlogId As Guid
<DataType(DataType.MultilineText)> <UIHint("Tags")> <DisplayName("Tags")>
Public Property PostTags As ICollection(Of be_PostTag)
<DisplayName("Category")> <UIHint("Categories")> Public Property
PostCategory As ICollection(Of CategoriesViewModel)
End Class
을 어떻게지도 할 Public Property PostCategory As ICollection(Of be_Categories)
당신이 CategoriesViewModel
에 be_Categories
에 대한 매핑을 작성하고 PostSummaryDTO
be_PostsViewModel
에 AutoMapper가 자동으로 이해됩니다 후
이 질문을 확인하십시오 http://stackoverflow.com/questions/13687240/c-sharp-automapper-map-collection-of-objects, 그것은 간단해야 Map < PostCategory, CategoriesViewModel>을 사용하면 컬렉션이나 목록이 있으면 충분합니다. –