Automapper 12 and custom Enum Type Converter #4231
shalinparmar
started this conversation in
NA
Replies: 1 comment
-
A value converter fits better here. Or you can workaround it using the context mapper. But we'll add that cast :) |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
https://gist.github.com/shalinparmar/8be92a90b45cc592abc8df82a3ea9a35
Source/destination types
Mapping configuration
Version: x.y.z
Automapper 12.0.1
Expected behavior
Actual behavior
System.ArgumentException
Expression of type 'System.Enum' cannot be used for assignment to type 'xxx.Model.Enums.LicenceType'
at System.Linq.Expressions.Expression.Assign(Expression left, Expression right)
at AutoMapper.Execution.TypeMapPlanBuilder.CreatePropertyMapFunc(MemberMap memberMap, Expression destination, MemberInfo destinationMember)
at AutoMapper.Execution.TypeMapPlanBuilder.AddPropertyMaps(List
1 actions) at AutoMapper.Execution.TypeMapPlanBuilder.CreateAssignmentFunc(Expression createDestination) at AutoMapper.Execution.TypeMapPlanBuilder.CreateMapperLambda() at AutoMapper.TypeMap.CreateMapperLambda(IGlobalConfiguration configuration) at AutoMapper.TypeMap.Seal(IGlobalConfiguration configuration) at AutoMapper.MapperConfiguration.<.ctor>g__Seal|20_0() at AutoMapper.MapperConfiguration..ctor(MapperConfigurationExpression configurationExpression) at AutoMapper.MapperConfiguration..ctor(Action
1 configure)Steps to reproduce
// Your calls to Mapper.Map or ProjectTo here, with source/destination objects constructed
.ForMember(d => d.Type, opt => opt.MapFrom(s => s.LicenceType))
Beta Was this translation helpful? Give feedback.
All reactions