【发布时间】:2019-02-26 19:06:11
【问题描述】:
我正在尝试将包含数组的对象映射到没有数组的对象列表中。例如:
假设我有这个对象:
public class SourceInformation {
public decimal Id { get; set; }
public Person[] People { get; set; }
...
}
人物类:
public class Person {
public string First { get; set; }
public string Last { get; set; }
public string Middle { get; set; }
}
我想映射到这个对象:
public class Destination {
public decimal Id { get; set; }
public string Name { get; set; }
...
}
但我想要的是,如果我的 People 属性中有 N 个 Person 对象,我希望在映射 <SourceInformation, Destination> 时返回 N 个 Destination 对象
每个Destination 对象都应具有相关的名称信息,但它们都将具有相同的Id 属性。
如何告诉 Automapper 1 个 SourceInformation 对象映射到 N 个 Destination 对象?
【问题讨论】:
标签: c# automapper