Advertisement
Guest User

Untitled

a guest
Mar 4th, 2015
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. public class Profile
  2. {
  3. public string Name { get; set; }
  4. public string SchoolGrade { get; set; }
  5. }
  6.  
  7. public class ProfileDTO
  8. {
  9. public string Name { get; set; }
  10. public SchoolGradeDTO SchoolGrade { get; set; }
  11. }
  12.  
  13. public enum SchoolGradeDTO
  14. {
  15. [Display(Name = "Level One"]
  16. LevelOne,
  17. [Display(Name = "Level Two"]
  18. LevelTwo,
  19. }
  20.  
  21. Mapper.CreateMap<Profile, ProfileDTO>()
  22. .ForMember(d => d.SchoolGrade , op => op.MapFrom(o => o.SchoolGrade))
  23.  
  24. Mapper.CreateMap<Profile, ProfileDTO>()
  25. .ForMember(d => d.SchoolGrade,
  26. op => op.ResolveUsing(o=> MapGrade(o.SchoolGrade)));
  27.  
  28. public static SchoolGradeDTO MapGrade(string grade)
  29. {
  30. //TODO: function to map a string to a SchoolGradeDTO
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement