Created
March 25, 2018 17:21
-
-
Save lbargaoanu/27b0d600e11d3da5d93eeb112949d67a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void Main() | |
{ | |
Mapper.Initialize(cfg=> | |
{ | |
}); | |
Mapper.AssertConfigurationIsValid(); | |
var book = new Book | |
{ | |
Name = "B1", | |
}; | |
book.Authors = new List<Author>{new Author{Name="A1",Books=new List<Book>{book}},new Author{Name="A2",Books=new List<Book>{book}}}; | |
var bookM = Mapper.Map<BookViewModel>(book).Dump(); | |
} | |
public class Book | |
{ | |
public string Name { get; set; } | |
public List<Author> Authors { get; set; } | |
} | |
public class Author | |
{ | |
public string Name { get; set; } | |
public List<Book> Books { get; set; } | |
} | |
public class BookViewModel | |
{ | |
public string Name { get; set; } | |
public List<AuthorViewModel> Authors { get; set; } | |
} | |
public class AuthorViewModel | |
{ | |
public string Name { get; set; } | |
public List<BookViewModel> Books { get; set; } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment