this post was submitted on 16 Jul 2023
14 points (100.0% liked)
.NET
1487 readers
2 users here now
Getting started
Useful resources
IDEs and code editors
- Visual Studio (Windows/Mac)
- Rider (Windows/Mac/Linux)
- Visual Studio Code (Windows/Mac/Linux)
Tools
Rules
- Rule 1: Follow Lemmy rules
- Rule 2: Be excellent to each other, no hostility towards users for any reason
- Rule 3: No spam of tools/companies/advertisements
Related communities
Wikipedia pages
- .NET (open source & cross platform)
- .NET Framework (proprietary & Windows-only)
founded 1 year ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
Wouldn't this work just as well?
ed => ed.ExampleProperty?.ExampleId
I can certainly test this. My question would then be, will this result in actually mapping a null in the dto, or would the .ExampleProperty? just "be null" and cause the long property to instantiate to 0?
i'm pretty sure it'll be a
long?
- did you try it?So.. When I change...
.ForMember(ee => ee.ExampleId, options => options.MapFrom(ed => ed.ExampleProperty != null ? ed.ExampleProperty.ExampleId : (long?)null))
TO:
.ForMember(ee => ee.ExampleId, options => options.MapFrom(ed => ed.ExampleProperty?.ExampleId))
I am presented with: CS8072 - An expression tree lambda may not contain a null propagating operator.
there you go! thanks for updating, good to know
One way to find out ;) not sure...