-
Notifications
You must be signed in to change notification settings - Fork 321
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can't use conditional mapping with different types of source field #673
Comments
The boolean conditional will be evaluated at runtime so the mapping when the int has a value needs to be defined to create a string from a nullable int.
|
Sad it's not possible. Because in real life it's not just I was thinking that this config would be roughly compiled into something like:
But seems like it's not. guess no other way that put everything into
|
For example there are 2 classes:
The task is put in
Mapped
string representation ofIntValue
if it's not null, otherwise useStringValue
. I assume configuration should look like (according to Mapster docs):But it gives runtime exception:
Is it intended behavior or it's a bug? How to perform conditional mapping in given case Mapster way, without slapping
.AfterMapping()
and do it with custom code?The text was updated successfully, but these errors were encountered: