daelmo wrote:
According to my test, if you save a dirty entity and then refetch, the IsDirty property is not false, as the entity is already saved, just the state of the entity is changed. Maybe you would need to work on some DataAccessAdapter fetch's events to catch a refetch.
I'm a bit confused by what you're stating. "Save dirty entity, then refetch, the IsDirty is NOT false" as in IsDirty=TRUE ???
That's not happenening in my case, although I do not refetch on my own after a save, I just pass in true to have your framework refetch. In my case, IsDirty=false all the time, but keep in mind, my issue has NEVER been that the state of IsDirty was ever wrong. IsDirty has always been the correct value.
The issue is that when your framework correctly does change IsDirty, it doesn't fire OnPropertyChanged("IsDirty"). I understand the issues you'd face trying to solve that since IsDirty is not really stored at the entity level. Still it would be a nice problem to solve, because WPF and xaml bindings rely heavily on objects notifying when something has changed so that they can update themselves.
daelmo wrote:
How do yo do it right now modifying the RTL sourcode anyway?
I added an OnPropertyChanged("IsDirty") to your EntityBase IsDirty setter. And then I just specifically added some calls to set this to False in some other places in your code. I don't think this is the right fix, just a fix I was trying to see if that's why my GUI wasn't updating. With this fix, my gui started working.
There are very few places in your code where you call IsDirty setter at the entity level, maybe just two or three. And the fields object doesn't have a reference back to the entity, not that I saw. That would have been ideal, just have the fields.IsDirty call an internal on the parent entity to raise the property notification. I think less than ideal is having the entity hook some event, I'd think that would affect performance. There are only about a dozen places or so in your code where you call the Fields IsDirty setter, and most are within EntityBase2 code, so another fix is to just go and call OnPropertyChanged("IsDirty") next to all of them, this is the fix I am tempted to go with as it seems the safest and the least likely to impact performance.
EDIT:
Although I am torn on whether or not I should add an OnIsDirtyChanged virtual and IsDirtyChanged event to the Fields that the entitybase hooks internally that the Fields is smart about raising ONLY when IsDirty does change. Then the entity can fire OnPropertyChanged("IsDirty") from it's own setter or the fields IsDirtyChanged event hook. Then the fix would not be splattered all over the app.