2012-09-17 4 views
2

Using DynamicMap() and ignore null source value 접근 방식을 사용하여 매퍼가 원본에서 NULL 값을 갖는 속성을 무시하지만 버전 2.1.267.0 (현재)에서는 작동하지 않습니다.AutoMapper IsSourceValueNull 조건이 작동하지 않습니다.

다음
Mapper.CreateMap<PersonDTO, Person>().ForAllMembers(
    opt => opt.Condition(srs => !srs.IsSourceValueNull)); 

내 시험이있어 :

// Arrange 
var Person = new Person { FirstName = "Bruce", Surname = "Lee"}; 
var PersonDto = new PersonDTO { FirstName = "Jet", Surname = null }; 

// Act 
Mapper.Map(PersonDto, Person); 

// Assert 
Assert.AreEqual("Jet", Person.FirstName); // Assert.AreEqual failed. Expected:<Jet>. Actual:<Bruce>. 
Assert.AreEqual("Lee", Person.Surname, "Surname field with NULL value should not have been mapped"); 

이 당신을 위해 작동합니까

여기 내 매핑 설정입니까? 그렇다면 내 코드에서 문제를 발견 할 수 있습니까?

답변

0

이것은 AutoMapper 버전 2.2에서 수정 될 예정입니다.

관련 문제