Configure AutoMapper to map to concrete types but allow Interfaces in the definition of my class

不问归期 提交于 2019-12-02 20:32:55

So I figured something that seems to work.

If I add these two mappings:

Mapper.CreateMap<SomethingFromWebService, Something>();
Mapper.CreateMap<SomethingFromWebService, ISomething>().As<Something>(); 

then it works as I want.

I have not been able to find any documentation on the 'As' method (try googling for that! :), but it seems to be a mapping redirection.

For example: For this Mapping (ISomething) resolve it As a Something.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!