Replies: 1 comment 1 reply
-
Maybe this example will help you? https://dotnetfiddle.net/NGEXhs
The output will be:
|
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I have a need to parse/convert strings to enums during integration between systems. The downstream system gives us strings that are converted to enums for processing. Using the example from documentation, the conversion sequence looks like this:
"S"
=>Source.Second
=>Destination.Second
I understand how to map
Source.Second
=>Destination.Second
, but I'm stuck on"S"
=>Source.Second
.I've tried
.CreateMap<string, Source>().ConvertUsingEnumMapping(opt => opt.MapByName("S", Source.Second))
, but the see this error:The type 'string' must be a non-nullable value type in order to use it as parameter 'TSource' in the generic type or method 'EnumMappingExpressionExtensions.ConvertUsingEnumMapping<TSource, TDestination>(IMappingExpression<TSource, TDestination>, Action<IEnumConfigurationExpression<TSource, TDestination>>)'
Is support for this scenario built in to
EnumMapping
, or is something like Custom Type Converter a better solution?Beta Was this translation helpful? Give feedback.
All reactions