【发布时间】:2014-06-30 00:38:49
【问题描述】:
我的 AutoMapper 配置有问题,我可以映射一个级别,但我不知道是否存在映射两个级别的方法
我有:
Class A
{
public int id {get; set;}
public string nom {get; set;}
public B Bprop {get; set;}
}
Class B
{
public int id {get; set;}
public string nom {get; set;}
public C Cprop {get; set;}
}
Class C
{
public int id {get; set;}
public string nom {get; set;}
}
我的配置代码如下,如果我从class B中删除Cprop,它就可以工作:
MapperTools<DatabaseA, A> mapperToolsService =
new MapperTools<DatabaseA, A>(MappingHelper);
mapperToolsService.MappingConfig.Configuration.CreateMap<DatabaseA, A>()
.ForMember(dest => dest.Bprop , opt => opt.MapFrom(src => src.DatabaseB));
mapperToolsService.MappingConfig.Configuration.CreateMap<DatabaseB,B>();
请问,我的代码有什么问题?
【问题讨论】:
标签: c# .net mapping automapper automapping