Я много раз искал, но не знаю, как собирать карты с помощью Automapper.Сопоставление коллекций с 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)
в Public Property PostCategory As ICollection(Of CategoriesViewModel)
проверить этот вопрос http://stackoverflow.com/questions/13687240/c-sharp-automapper-map-collection-of-objects, он должен быть простым, всего на карте < PostCategory, CategoriesViewModel>, и этого будет достаточно, если у вас есть коллекция или список. –