开发者

AutoMapper AssertConfiguration at compile time?

Is there any way to validate mappings at compile time? For example, I have an entity with many child entities. If I forgot to add a CreateMap for one of the childen when I try to map ParentX to ParentY the mapping will fail.

I can't think of a way to validate this during开发者_StackOverflow compile but I'd love to find a way.


No, there's not a clean way to do so. You could try a post-build hook to call a unit test, but that's not much different than actually executing a unit test. In our experience, we just keep the AutoMapper configuration unit test open while we build our ViewModels, verifying as we go.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜