Mapper.CreateMap<BusinessObject, Proxy.DataContacts.DCObject>()
.ForMember(x => x.ExtensionData, y => y.Ignore())
.ForMember(z => z.ValidPlaces, a=> a.ResolveUsing(typeof(ValidPlaces)));
Mapper.AssertConfigurationIsValid();
proxydcObject = Mapper.Map<BusinessObject, Proxy.DataContracts.DCObject>(_instanceOfBusinessObject); //throws an exception saying ValidPlaces could not be resolved
public class BusinessObject
{
public Enum1 Enum1 { get; set; }
public List<ValidPlaces> ValidPlaces{ get; set; }
}
public class ValidPlaces
{
public int No { get; set; }
public string Name { get; set; }
}
public class DCObject
{
[DataMember]
public Enum1 Enum1 { get; set; }
[DataMember]
public List<ValidPlaces> ValidPlaces{ get; set; }
}
Mapper.CreateMap 工作查找何时Mapper.AssertConfigurationIsValid();
调用(此行上没有抛出异常),但是当我实际调用下一行的 WCF 服务时,此处未显示 Automapper 抛出和异常说 ValidPlaces 无法映射。如果我可以正常工作将 Ignore() 放在 ValidPlaces 属性上,但理想情况下希望它通过。
任何 AutoMapper 专家都请提供帮助。