-
Notifications
You must be signed in to change notification settings - Fork 338
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
Mapping nullable Enum to custom object #640
Comments
I've figured a way out but still think it might be a better if we've somthing more helpful in the config. Especially from primitive types to classes. Anyways, my solution was simply like the following:
|
Hello @WahidBitar , if your goal is to skipped mapping when the TSource is null, maybe your help .IgnorIf() |
Hello @WahidBitar, I ran into this problem while preparing a fix for the problem record detection. Please add sample Type of KeyValueData. To make it easier to understand which way the processing is going |
Thanks @DocSvartz , My main goal is not to skip the null values. My goal is to map from a nullable enum to my custom class Note: you may found something weard in my Mapping config:
the KeyValueData class:
|
@WahidBitar, I wanted to see the KeyValueData in order to better help you.
You use Record only as immutable type ? Or you used in this time mutable behavior from update. Example:
|
Hello @WahidBitar , In version Mapster 7.4.0 and Mapster Tool 8.4.0 (Net 7.0) it working from your last example: not Error
Result of generation:
|
thank you so much @DocSvartz
so I ended up with my workaround solution |
I get you Error Result. Try found problem :) |
@DocSvartz Yes I prefer a separate PR :) Thanks for all your recent contributions, amazing work! |
Fix to issue #640 - Nullable Emun to Nullable Destination (Class or param) - Need Sample for testing
In order to identify issues that are still active, we are closing issues that we believe are either resolved or are dormant. If your issue is still active then please reopen. Thanks. |
for now I can have something like the following to register mapping for all enums in the system
However, it's not possible to have the same cofig for a nullable Enum.
The following config is not working:
I'll get the following Exception
Error while compiling
source=Tests.FirstClass
destination=Tests.SecondClass
type=Map
-> InnerException:
Error while compiling
source=System.Nullable`1[Model.IdentityType]
destination=Model.KeyValueData
type=Map
--> InnerException:
No default constructor for type 'KeyValueData', please use 'ConstructUsing' or 'MapWith'
The text was updated successfully, but these errors were encountered: