Cannot map from nullable type using ForCtorParam #4070
TannerStrike
started this conversation in
NA
Replies: 2 comments
-
I ended up getting this to work if I change the code to this: public record CatalogDetails(CatalogAmount? MinTransactionAmountzzz); //with zzz at the end
CreateMap<Offer, CatalogDetails>()
.ForCtorParam(nameof(CatalogDetails.MinTransactionAmountzzz), opt => opt.MapFrom(src => getCatalogAmount(src.MinTransactionAmount))); Its like I am manually setting up the mapping, but AutoMapper is still trying to automap from |
Beta Was this translation helpful? Give feedback.
0 replies
-
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.
-
Hello,
I am running into an issue when trying to map from a
decimal?
to a nullable type. Here is my setup:As you can see, all I want to do is simply map
decimal?
value onOffer
to aCatalogAmount?
, however I am getting this exception:All I can determine is that there is some issue with mapping from a nullable type using
ForCtorParam
? I have tried numerous null-checks, but cannot get this to work.Any ideas?
Beta Was this translation helpful? Give feedback.
All reactions