ProjectTo with value converters #3652
0x5ECF4ULT
started this conversation in
NA
Replies: 1 comment
-
https://docs.automapper.org/en/latest/Queryable-Extensions.html#supported-mapping-options |
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.
-
TL;DR: There might be a bug when AutoMapper tries to handle
Byte
s andChar
s.When building a REST application (not relevant) I ran into a potential bug in AutoMapper. When converting a
byte[]
tostring
without a custom converter, an exception is thrown. I googled a bit around and eventually found out that this behaviour has been removed (#1153). The workaround is to implement two converters (as written below) and upon retry I was greeted with another exception (System.InvalidOperationException: Missing map from System.Byte to System.Char. Create using Mapper.CreateMap<Byte, Char>
). Well I did that and hoped it would finally work. The result is the stacktrace below.Source/destination types
Source type (EFCore mapped model)
Destination type
Mapping configuration
Version: x.y.z
AutoMapper.Extensions.Microsoft.DependencyInjection
: 8.1.1AutoMapper
: 10.1.1Microsoft.EntityFrameworkCore.Sqlite
: 5.0.5Expected behavior
string
/byte[]
objects get converted into their couterpart (eg.string
->byte[]
or the other way around).Actual behavior
An exception is thrown (
System.ArgumentException: Argument types do not match
)For brevity I have only attached the relevant part of the stacktrace.
Steps to reproduce
Beta Was this translation helpful? Give feedback.
All reactions