Hello ,
I have upgraded old Automapper to newest , now my code don't run like expected.
class DemoDTO
{
public string FirstName { get; set; }
public string LastName { get; set; }
public int? VacationDays { get; set; }
public DateTime? BirthDay { get; set; }
public Double? LoanAmount { get; set; }
}
var config = new MapperConfiguration(cfg => {
cfg.AllowNullCollections = true;
cfg.CreateMap<DemoDTO, DemoDTO>()
.ForAllMembers(opt => opt.Condition((src, dest, srcMember, destMember) => srcMember != null));
});
IMapper iMapper = config.CreateMapper();
#endregion
var destination = new DemoDTO()
{
FirstName = "M",
LastName = "M",
LoanAmount = 2000
};
var source = new DemoDTO() { FirstName = "Micky", LastName = "Mouse" };
destination = iMapper.Map<DemoDTO, DemoDTO>(source);
I am updating my entity from WebAPI , if source have any NULL values this should not be mapped with my DESTINATION
Executing this mapping , overwrite all my fields with source , and Ignorre my Condition , bug or why happend this ?