Advertisement
Guest User

Untitled

a guest
Jul 25th, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. public class Person
  2. {
  3. public string name;
  4. public List<Group> groups;
  5. }
  6.  
  7. public class Group
  8. {
  9. public string name;
  10. public List<Person> members;
  11. }
  12.  
  13. public class PersonDTO
  14. {
  15. public string name;
  16. public List<GroupDTO> groups;
  17. }
  18.  
  19. public class GroupDTO
  20. {
  21. public string name;
  22. public List<PersonDTO> members;
  23. }
  24.  
  25. CreateMap<Person, PersonDTO>()
  26. .ForMember(x => x.groups.Select(y => y.members), opt => opt.Ignore())
  27. .ReverseMap();
  28.  
  29. CreateMap<Group, GroupDTO>()
  30. .ForMember(x => x.members.Select(y => y.groups), opt => opt.Ignore())
  31. .ReverseMap();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement