我正在尝试使用 AutoMapper,它除了 int 属性外它工作得很好,因为它只是用 0 替换了字段
代码:
public class Employee
{
public int E1 { get; set; }
public int E2 { get; set; }
}
Mapper.CreateMap<Employee, Employee>().ForAllMembers(opt => opt.Condition(srs => !srs.IsSourceValueNull));
Employee e1 = new Employee {E1 = 7};
Employee e2 = new Employee {E2 = 78};
Mapper.Map(e2, e1);
//结果 //E1 = 0, E2 = 78.... 它应该只映射 E2 并留下 E1 因为我没有初始化它?