当我将未标记的字段标记为“ MapAtRuntime”时,为什么AutoMapper会报告未映射的字段?

时间:2019-05-24 14:00:03

标签: automapper

我有此个人资料:

public class FooToBarProfile : Profile
{
    public FooToBarProfile()
    {
        CreateMap<Foo, Bar>()
            .ConstructUsing(x => new Bar())
            .ForMember(d => d.Name, opt => opt.MapFrom(s => s.FirstName))
            .ForMember(d => d.Baz, opt => opt.MapAtRuntime())
            .AfterMap((src, dest, context) => dest.Baz = GetSomethingFromSomewhere());
    }
}

当我验证配置时,我看到

Unmapped members were found. Review the types and members below.
Add a custom mapping expression, ignore, add a custom resolver, or modify the source/destination type
For no matching constructor, add a no-arg ctor, add optional arguments, or map all of the constructor parameters
===================================================================================================================================================
Foo -> Bar (Destination member list)
MyApp.Foo -> MyApp.Bar (Destination member list)

Unmapped properties:
Baz

我告诉AutoMapper我正在运行时映射它,为什么将它报告为未映射成员?

0 个答案:

没有答案