我想使用AutoMapper映射类,但也要阻止源参数映射。
public class Dest
{
public string strInclude { get; set; }
}
public class Source
{
public string strInclude { get; set; }
public string strIgnore { get; set; }
}
Mapper.CreateMap<Dest, Source>()
//code to prevent strIgnore from mapping over to Dest
我可以找到很多忽略目标参数的例子,例如
Mapper.CreateMap<Dest, Source>()
.ForMember(dest => dest.strIgnore, src => src.Ignore());
然而,我似乎无法找到相反的情况。提前致谢