using System.Collections.Generic;
public static void Main()
var mapper = new MapperConfiguration(cfg => {
cfg.CreateMap<SourceQuestionnaireSubmission, DestQuestionnaireSubmission>()
.ForMember(d => d.ParticipantId, d => d.MapFrom(s => s.ParticipationId))
.ForMember(d => d.SurveyVersionId, d => d.MapFrom(s => s.Survey.Version))
.ForMember(d => d.RespondantAnswers, d => d.MapFrom(s => s.States));
cfg.CreateMap<State, RespondantAnswer>()
.ForMember(d => d.QuestionId, d => d.MapFrom(s => s.QuestionId));
var source = new SourceQuestionnaireSubmission
Survey = new Survey { Version = 10 },
States = new [] { new State { QuestionId = 100 }, new State { QuestionId = 999 } }
var dest = mapper.Map<SourceQuestionnaireSubmission, DestQuestionnaireSubmission>(source);
Console.WriteLine("ParticipantId: {0}", dest.ParticipantId);
Console.WriteLine("SurveyVersionId: {0}", dest.SurveyVersionId);
Console.WriteLine("RespondantAnswers: {0}", string.Join(", ", dest.RespondantAnswers.Select(a => a.QuestionId)));
public class SourceQuestionnaireSubmission
public int ParticipationId { get; set; }
public Survey Survey { get; set; }
public State[] States { get; set; }
public int Version { get; set; }
public int QuestionId { get; set; }
public class DestQuestionnaireSubmission
public int ParticipantId { get; set; }
public int SurveyVersionId { get; set; }
public IEnumerable<RespondantAnswer> RespondantAnswers { get; set; }
public class RespondantAnswer
public int QuestionId { get; set; }