I have an entity update method that is setting one of my key columns in one of my related tables for the entity with a NULL.
The issue happens from the Edit modal to the update company method in my app service. It updates the company entity table just fine. But then it seems to also NULL out the company Id column in my CompanyAddress table.
I have emailed you my solution for your review. Can you help to identify why this is happening? Thanks!
3 Answer(s)
-
0
Hi,
Sorry for the late reply, I have missed your email somehow. If you move this definition in EditCompanyDtoForUpdate
public List<EditCompanyAddressDto> Addresses { get; set; }
to EditCompanyDto, your problem will be solved.
You don't send address data when updating company but you map your dto to company entity. In this way, entities Addresses list becomes empty and your filed updated as null.
-
0
Thank you very much! That did the trick!
I'm still struggling to come to grips with these DTO's. But I'm learning slowly! :D
-
0
Hi,
I'm glad that it worked :).