Fody/PropertyChanged

"IsChanged" boolean property on the object set to true when mapping objects

sekulicb opened this issue · 3 comments

Hi. Thanks for the library. We have dto object that contains 30 or so properties, and one of them is called IsChanged, which marks the object as changed according to some business logic. We manually set this property to true, but only after certain operation is done on the UI.

The problem comes when we load the data from the database. On initial load we have ~ 6000 items, and around 400 of them come with IsChanged == true for some reason. We use AutoMapper to map from Entity -> Dto and this property can only be changed on the UI. Renaming this property to "Changed" or anything else solved the problem. Later I have found that ModuleWeaver is searching for property with the same name:

MicrosoftTeams-image (1)

  • Fody 6.2.0
  • Any Fody weavers being used : only property changed in this project
  • netcoreapp3.1

Hi, this feature is documented here.

I'm not sure what you're trying to report here. I suppose it's weird that only 400 items out of 6000 are marked as changed, I'd expect them all to be marked as changed. Anyway, it's normal for the property to be set to true while calling a property setter with a value different from the default. You should set it back to false after the items are loaded.

@sekulicb just to config: are all your devs that are using Fody also patrons on OpenCollective https://github.com/Fody/Home/blob/master/pages/licensing-patron-faq.md ?

@ltrzesniewski My bad, I didn't see it in the docs. Yes it's very weird. We have set a foreach loop for collection to default this property to false for each item, but it still remains to true.

@SimonCropp No, I don't have an ownership of the code, everything belongs to the client, we just do coding services.