ITypeConverter interface has been changed in AutoMapper 2.0

后端 未结 1 1787
执念已碎
执念已碎 2021-02-13 13:04

The ITypeConverter interface has been changed to have a \"TDestination Convert(ResolutionContext context)\" instead of \"TDestination Convert(TSource source)\" for the Convert m

相关标签:
1条回答
  • 2021-02-13 13:28

    You'll have to grab the decimal from the ResolutionContext.SourceValue property:

        public int? Convert(ResolutionContext context)
        {
            var d = (decimal)context.SourceValue;
            if (d == 0)
            {
                return null;
            }
            return (int) d;
        }
    
    0 讨论(0)
提交回复
热议问题