Generic mapping with Automapper

て烟熏妆下的殇ゞ 提交于 2019-12-13 05:23:41

问题


I would like to create a generic/common mapping that will be the equivalent of the following mappings but with single line.

cfg.CreateMap<int?, PropertyModel<int?>>().ConvertUsing<ValueToPropertyModelConverter<int?>>();

cfg.CreateMap<double?, PropertyModel<double?>>().ConvertUsing<ValueToPropertyModelConverter<double?>>();

cfg.CreateMap<string, PropertyModel<string>>().ConvertUsing<ValueToPropertyModelConverter<string>>();

I would imagine something like

cfg.CreateMap<TValue, PropertyModel<TValue>>().ConvertUsing<ValueToPropertyModelConverter<TValue>>();

Any ideas ?

Thanks !

Riana

来源:https://stackoverflow.com/questions/49381319/generic-mapping-with-automapper

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