Advertisement
Guest User

Untitled

a guest
Sep 30th, 2016
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 KB | None | 0 0
  1. public class EmbeddedInBar
  2. {
  3. public string Name { get; get; }
  4. public IEnumerable<int> ListOfInts { get; set; }
  5. }
  6.  
  7. public class Bar
  8. {
  9. public int Id { get; set; }
  10. public string Name { get; set; }
  11. public IEnumerable<int> ListOfInts { get; set; }
  12. public EmbeddedInBar Embedded { get; set; }
  13. }
  14.  
  15. var destination = new Bar
  16. {
  17. Id = 1,
  18. Name = "Destination",
  19. ListOfInts = new List<int>( 1,2,3 },
  20. Embedded = new EmbeddedInBar
  21. {
  22. Name = "DestinationEmbedded",
  23. ListOfInts = new List<int>( 4,5 }
  24. }
  25. };
  26.  
  27. var source = new Bar
  28. {
  29. Id = 2,
  30. Name = "Source",
  31. ListOfInts = new List<int>( 6,7,8 },
  32. Embedded = new EmbeddedInBar
  33. {
  34. Name = "SourceEmbedded",
  35. ListOfInts = new List<int>( 9,10 }
  36. }
  37. };
  38.  
  39. destination = Mapper.Map(source, destination);
  40.  
  41. {
  42. Id: 2,
  43. Name: "Source",
  44. ListOfInts: [ 1,2,3,6,7,8 ]
  45. Embedded: {
  46. Name: "SourceEmbedded",
  47. ListOfInts: [ 4,5,9,10 ]
  48. }
  49. }
  50.  
  51. {
  52. Id: 2,
  53. Name: "Source",
  54. ListOfInts: [ 6,7,8 ]
  55. Embedded: {
  56. Name: "SourceEmbedded",
  57. ListOfInts: [ 9,10 ]
  58. }
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement