UPDATE. Never mind, this code solved the problem
Mapper.CreateMap<EditSalespointViewModel, SalesPt>()
.ForMember(dest=>dest.Salespoint, opt=>opt.MapFrom(source=>source.SalespointKey))
.ForMember(dest =>dest.ScanOnly,
opt => opt.ResolveUsing<ByteToBooleanResolver>().FromMember(source => (Byte) source.ScanOnly));
Hi everybody,
In my model I have Boolean column. In the View Model I defined this column (property) as public Enum (type Byte).
In my AutoMapper config I have
.ForMember(dest =>dest.ScanOnly,
opt => opt.ResolveUsing<ByteToBooleanResolver>().FromMember(source => source.ScanOnly));
However, I get an error here
AutoMapper.AutoMapperMappingException was unhandled by user code
HResult=-2146233088
Message=Value supplied is of type SysManager.Common.Enums.AllowablePassNumberEntryMethods but expected System.Byte.
Change the value resolver source type, or redirect the source value supplied to the value resolver using FromMember.
Value supplied is of type SysManager.Common.Enums.AllowablePassNumberEntryMethods but expected System.Byte.
Change the value resolver source type, or redirect the source value supplied to the value resolver using FromMember.
I don't want to write custom resolver. I can, of course, just change the value in the view model to be Byte and not Enum, but is there is way to somehow fix it in the config?
I tried
dest=> Convert.ToByte(dest.ScanOnly)
but this can not be done. So, do you see my problem and how can I resolve it?
Thanks in advance.
If it's not broken, fix it until it is.
My Blog