【问题标题】:Automapper expression must resolve to top-level memberAutomapper 表达式必须解析为顶级成员 【发布时间】:2012-07-22 21:33:35 【问题描述】:
我正在使用自动映射器来映射源对象和目标对象。当我映射它们时,我得到以下错误。
表达式必须解析为顶级成员。参数名称:lambdaExpression
我无法解决问题。
我的源和目标对象是:
public partial class Source
{
private Car[] cars;
public Car[] Cars
{
get { return this.cars; }
set { this.cars = value; }
}
}
public partial class Destination
{
private OutputData output;
public OutputData Output
{
get { return this.output; }
set { this.output= value; }
}
}
public class OutputData
{
private List<Cars> cars;
public Car[] Cars
{
get { return this.cars; }
set { this.cars = value; }
}
}
// First: create mapping for the subtypes
Mapper.CreateMap<Source, OutputData>();
// Then: create the main mapping
Mapper.CreateMap<Source, Destination>().
// chose the destination-property and map the source itself
ForMember(dest => dest.Output, x => x.MapFrom(src => src));