I have a source class like this:
public class SuspenseRequest
{
public string LineOfBusiness { get; set; }
public string SuspendedTo { get; set; }
public string DbAction { get; set; }
public string OfficeName { get; set; }
public string Priority { get; set; }
public string State { get; set; }
}
My destination class is:
public class SearchCriteria
{
public Guid Id { get; set; }
public string ParameterName { get; set; }
public string ParameterValue { get; set; }
public bool isProcessed { get; set; }
}
What I am trying to do is to map the property names of SuspenseRequest
to ParameterName
from the SearchCriteria
class. So LineOfBusiness
property or SuspendedTo
property or DbAction
property is mapped to ParameterName
So I tried to define the following mapping and I am stuck at this point where when I use to getProperty method, it is asking me to pass in the string:
CreateMap<SuspenseRequest, SearchCriteria>()
.ForMember(dest => dest.ParameterName, opt => opt.MapFrom(src => src.GetType().GetProperty(opt.));
How do I perform this mapping with Automapper? Thanks in advance
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…