AutoMapper SourceMemberNameTransformer
我想为我在许多域对象和关联视图模型上拥有的属性注册自定义命名约定。
域对象有一个枚举属性 PublishStatus
,视图模型有一个布尔属性 Published
。
如果我创建一个自定义 SourceMemberNameTransformer
就像 如何让 AutoMapper 处理自定义命名约定?,我是否只返回与 PublishStatus
不匹配的属性的原始字符串?
I wanted to register a custom naming convention for a property that I have on a number of domain objects and associated view models.
The domain object has an enum property PublishStatus
and the view model has a boolean property Published
.
If I create a custom SourceMemberNameTransformer
like on How do I get AutoMapper to deal with a custom naming convention?, do I just return the original string for properties that don't match PublishStatus
?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果我正确理解你的问题,你可能需要一个
ValueResolver
。像这样:然后在映射代码中你可以这样称呼它:
If I understand your question properly you probably want a
ValueResolver
. Something like:Then in mapping code you call it like: