开发者

How do I debug AutoMapper.AutoMapperMappingException

开发者 https://www.devze.com 2023-01-30 03:58 出处:网络
Is there some way to get some more detail from automapper when I get this exception: AutoMapper.AutoMapperMappingExce开发者_如何转开发ption

Is there some way to get some more detail from automapper when I get this exception:

AutoMapper.AutoMapperMappingExce开发者_如何转开发ption

Often it will tell me the 2 types of the mapping, but not which resolver or part of the mapping is failing.


Simple answer, is to call this method, preferably in your unit test.

// ensure your configuration mappings are loaded first (bootstrapper)
Mapper.AssertConfigurationIsValid();

see: http://docs.automapper.org/en/stable/Getting-started.html#how-do-i-test-my-mappings


One thing that fixed my problem was adding this line to the mapping.

.ForAllMembers(op=>op.Condition(x=>!x.IsSourceValueNull));

Not sure why this isn't the default behavior.

0

精彩评论

暂无评论...
验证码 换一张
取 消