这些是我的课程:
public class EventLog {
public string SystemId { get; set; }
public string UserId { get; set; }
public List<Event> Events { get; set; }
}
public class Event {
public string EventId { get; set; }
public string Message { get; set; }
}
public class EventDTO {
public string SystemId { get; set; }
public string UserId { get; set; }
public string EventId { get; set; }
public string Message { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
基本上我需要从具有嵌套列表的单个对象到具有嵌套列表和父对象的值的对象列表.可以在AutoMapper中完成吗?我意识到我可以轻松映射事件列表并获取EventDTO对象列表,然后手动设置SystemId和UserId,让AutoMapper为我处理它会非常方便.