简体   繁体   English

在 AutoMapper 中覆盖类型映射

[英]Override type mapping in AutoMapper

I've got the following...我有以下...

Mapper.CreateMap<string, string>().ConvertUsing(x => x.Clean());

...but I only want to use this mapping when mapping between some types. ...但我只想在某些类型之间进行映射时使用此映射。 If this mapping were to be the default, how could I override it for selected types?如果此映射是默认值,我如何为选定类型覆盖它?

Cheers, Ian.干杯,伊恩。

Ok, new try;)好的,新的尝试;)

Maybe you could use Ignore() If() and Skip() to achieve your goal.也许您可以使用 Ignore() If() 和 Skip() 来实现您的目标。 If you can figure out from the string what you should do with it.如果你能从字符串中找出你应该用它做什么。

Bit like in this question: Automapper: Ignore on condition of有点像这个问题: Automapper:忽略条件

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM