zeroadam

joined 2 years ago
[–] zeroadam 1 points 1 year ago* (last edited 1 year ago) (1 children)

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.

[–] zeroadam 1 points 1 year ago (4 children)

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?

[–] zeroadam 6 points 1 year ago

At first "glance", if you're looking to get into DevOps, then a deployment engineer should be a good match. I suppose it depends on the company and what they really want vs the job req description. As a Release Engineer, you would need to have (or get on the job) skills with CI/CD pipelines (build/release), branch management and release merging/tagging, and so on. Again, it depends what the company is really doing or wanting from that role.

 

While implementing AutoMapper in some existing code, I came across the need to map to a nullable property. Other business logic relied on this particular long being null instead of 0. The DTO has a property that contains a (long)Id, but the Entity contains the virtual property as well as a nullable long? of the Id. Anyway after fumbling through a few tries, I finally came upon the solution and wanted to share it here.

In the MapperProfile for the direction of DTO to Entity you have to do a null check, but the trick for me was having to explicitly cast to (long?)null.

CreateMap<ExampleDto, ExampleEntity>().ForMember(ee => ee.ExampleId, options => options.MapFrom(ed => ed.ExampleProperty != null ? ed.ExampleProperty.ExampleId : (long?)null)).NoVirtualMap();

Hope someone else finds this helpful, and finds it here.

[–] zeroadam 4 points 1 year ago

You could do a series and post it to the [email protected] community. Or are you looking to have a separate community specifically focused on learning and such that isn't mixed in with all the other c# topics and discussions?

[–] zeroadam 1 points 2 years ago

I like option 1 and option 2. Option 2 seems easier to differentiate, as others have mentioned.

[–] zeroadam 5 points 2 years ago

I enjoy Nick Chapsas videos as @[email protected] mentions. Other videos that pop up end up being "day in the life" type stuff rather than instructional/information content.