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 works find when Mapper.AssertConfigurationIsValid();
(No exceptions thrown on this line) is called but
when I actually call into the WCF service on the next line which is not shown here the Automapper throws and exception saying ValidPlaces could not be mapped.Works fine if I put Ignore() on the ValidPlaces property but ideally want that passed.
Any AutoMapper experts out there pls help.