Advertisement
Guest User

Untitled

a guest
Dec 12th, 2019
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.56 KB | None | 0 0
  1. public static string NullString(this Entity e)
  2. {
  3.     return e?.ToString();
  4. }
  5.  
  6. public class ServiceRequest_Simple : IMapFrom<ServiceRequest>
  7. {
  8.     public string Room { get; set; }        //Room (Entity)
  9.     public string Initiator { get; set; }   //User (Entity)
  10.  
  11.     public void Mapping(Profile profile)
  12.     {
  13.         profile.CreateMap<ServiceRequest, ServiceRequest_Simple>()
  14.             .ForMember(dto => dto.Room, o => o.MapFrom(n => n.Room.NullString()))
  15.             .ForMember(dto => dto.Initiator, o => o.MapFrom(n => n.Initiator.NullString()))
  16.     }
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement