Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Profile
- {
- public string Name { get; set; }
- public string SchoolGrade { get; set; }
- }
- public class ProfileDTO
- {
- public string Name { get; set; }
- public SchoolGradeDTO SchoolGrade { get; set; }
- }
- public enum SchoolGradeDTO
- {
- [Display(Name = "Level One"]
- LevelOne,
- [Display(Name = "Level Two"]
- LevelTwo,
- }
- Mapper.CreateMap<Profile, ProfileDTO>()
- .ForMember(d => d.SchoolGrade , op => op.MapFrom(o => o.SchoolGrade))
- Mapper.CreateMap<Profile, ProfileDTO>()
- .ForMember(d => d.SchoolGrade,
- op => op.ResolveUsing(o=> MapGrade(o.SchoolGrade)));
- public static SchoolGradeDTO MapGrade(string grade)
- {
- //TODO: function to map a string to a SchoolGradeDTO
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement