using System.Collections.Generic;
public static void Main() {
var mapper = new Mapper(new MapperConfiguration(cfg => {
cfg.CreateMap<PostTag, TagDto>()
.ForMember(d => d.Name, o => o.MapFrom(s => s.Tag.Name));
cfg.CreateMap<Post, PostDto>()
.ForMember(d=> d.PostTags, o=>o.MapFrom(s=>s.PostTag));
var posts = new List<Post> {
new Post {Title = "Post1", PostTag = new List<PostTag>{new PostTag{Tag = new Tag{Name="tag1"}}}},
new Post {Title = "Post2", PostTag = new List<PostTag>{new PostTag{Tag = new Tag{Name="tag2"}}}},
var postDtos = mapper.Map<List<PostDto>>(posts);
public string Title { get; set; }
public List<PostTag> PostTag { get; set; }
public string Name { get; set; }
public List<PostTag> PostTags { get; set; }
public Post Post { get; set; }
public Tag Tag { get; set; }
public string Title { get; set; }
public List<TagDto> PostTags { get; set; }
public string Name { get; set; }