Suppose I have the following classes
public class Parent {
public int ParentId { get; set; }
public List<Child> Children{get; set; }
// other properties
}
public class Child {
public int ChildId { get; set; }
// other properties
}
public class ParentVm {
public int ParentId { get; set; }
public List<ChildVm> Children{get; set; }
// other properties
}
public class ChildVm {
public int ParentId { get; set; }
public int ChildId { get; set; }
// other properties
}
Parent parent = /*something*/
var parentVm = Mapper.Map<ParentVm>(parent);
In the ChildVm, there is property ParentId. How can I propagate that value to using automapper?

ChildVm.ParentIdto anything. Also, it appears that yourMapper.Mapcommand is backward if you are trying to create aParentVm, as that line will create aParentobject. Is the real use case trying to map aParentobject, which hasChildobjects to aParentVmwhich hasChildVmobjects? And to have theParent.ParentIdproperty propagate to theChildVm.ParentIdproperty?