我仍然对何时在 automapper 中使用 Value Formatter 和 Value Resolver 感到困惑。
假设我有一个可为空的 DateTime,我想将它转换为特定的日期格式(因此最终结果将是一个字符串)。在这种情况下我应该使用格式化程序吗?
谢谢
最佳答案
我有同样的问题,并根据作者本人的文档选择了 Value Resolver,即 Value Formatter 可能是设计错误:
https://github.com/AutoMapper/AutoMapper/wiki/Custom-value-formatters
但是,同一位作者对此处使用的内容做出了回应:
Why does AutoMapper have an IValueFormatter when it has a seemingly much more powerful ValueResolver?
关于automapper - 何时使用值格式化程序以及何时使用值解析器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7474108/