I have the following two classes:
public class DomainStudent {
public long Id { get; set; }
public string AdvisorId { get; set; }
public long? DegreeId { get; set; }
}
public class ApiStudent {
public long Id { get; set; }
public long AdvisorName { get; set; }
public long? DegreeId { get; set; }
}
When I run the following mapping:
Mapper.CreateMap<ApiStudent, DomainStudent>();
var api = new ApiStudent();
api.Id = 123;
api.AdvisorName = "Homer Simpson";
api.DegreeId = null;
var domain = new DomainStudent();
domain.Id = 123;
domain.AdvisorName = "Marge Simpson";
domain.DegreeId = 5; // i want this to get written to null
Mapper.Map(api, domain);
// at this point domain.DegreeId = 5 instead of null
I would have thought this worked by default. Am I missing something?