0
我在.NET EF項目中使用AutoMapper 6.0.2,我似乎無法使AutoMapper工作。AutoMapper生成異常
在這種使用AutoMapper 4.x.x本教程中使用:
class A
{
string Id;
string Name;
B test {get; set;}
}
class B
{
string Id;
string Name;
C test{ get; set;}
}
class C
{
string Name;
}
Mapper.CreateMap<C, CDto>();
Mapper.CreateMap<B, BDto>();
Mapper.CreateMap<A, ADto>();
return entities.Select(Mapper.Map<A, ADto>);
我在下面試過,但我總是異常後,當我使用Mapper.Map。
var config = new MapperConfiguration(cfg =>
{
cfg.CreateMap<C, CDto>();
cfg.CreateMap<B, BDto>();
cfg.CreateMap<A, ADto>();
});
和
Mapper.Initialize(cfg =>
{
cfg.CreateMap<C, CDto>();
cfg.CreateMap<B, BDto>();
cfg.CreateMap<A, ADto>();
});
什麼是異常消息? – CodeNotFound