Automapper Set Decimals to all be 2 decimals
问题 I want to use AutoMapper to link up two of my objects. It is working well but now I want to format my decimal items to all round to 2 decimals. This is what I have. What am I doing wrong? Mapper.CreateMap<Object1, Object2>() .ForMember(x => typeof(decimal), x => x.AddFormatter<RoundDecimalTwo>()); Here is the RoundDecimalTwo Formatter public class RoundDecimalTwo : IValueFormatter { public string FormatValue(ResolutionContext context) { return Math.Round((decimal)context.SourceValue,2)