Hello Members,
I am very new to automapper and need your help in order to find the solution. I have a list of properties which is at a different level in the source and I want to map it to a list that is at different level of destination.
Please see the example below.
Source:
Class ExamObject{
public long id { get; set; }
public virtual Question Question { get; set; }
}
Class Question{
public long id { get; set; }
public virtual ICollection<QuestionLanguage> QuestionLanguage { get; set; }
public virtual ICollection<QuestionOption> QuestionOption { get; set; }
}
Class QuestionLanguage
{
public long id {get;set;}
public string text {get;set;}}
}
Class QuestionOption
{
public long id {get;set;}
public virtual ICollection<QuestionOptionLanguage> QuestionOptionLanguage { get; set; }
}
Class QuestionOptionLanguage
{
public long id {get;set;}
publice text {get;set}
}
Destination Object:
Class Questiondto{
public long id {get;set;}
public string QuestionText {get;set;}
public List<Answer> Answers { get; set; }
}
class answer{
public long id {get;set;}
publice answertext {get;set}
}
I want to map examobject to Questiondto in such a way that
1. "ICollection<QuestionOptionLanguage> QuestionOptionLanguage" map to "List<Answer> Answers"
2. QuestionLanguage[0].Text to Questiondto.QuestionText
if someone can help me out then it will be appreciated.