I need to map to a protected property on a class using Automapper. I've got a public method exposed on this class that is used to set values to the property. This method requires a parameter. How can I map a value to this class?
Destination Class:
public class Policy { private Billing _billing; protected Billing Billing { get { return _billing; } set { _billing = value; } } public void SetBilling(Billing billing) { if (billing != null) { Billing = billing; } else { throw new NullReferenceException("Billing can't be null"); } } } Here's what my Automapper code (pseudo code) looks like:
Mapper.CreateMap<PolicyDetail, Policy>() .ForMember(d => d.SetBilling(???), s => s.MapFrom(x => x.Billing)); I need to pass a Billing class to the SetBilling(Billing billing) method. How do I do this? Or, can I just set the protected Billing property?