when IsDirty is Dirty ?

Posts   
 
    
omar avatar
omar
User
Posts: 569
Joined: 15-Oct-2004
# Posted on: 19-May-2005 16:03:25   

Greetings, I always thought of an entity's IsDitry as a flag for when any of the entity's fields is changed. The problem is when an entity is loaded from the database (like when loading a collection from the database); in that case also the entity's IsDirty is True. What I really need is a flag for when the entity's fields become dirty by assignment (from code or UI) and not by loading from the DB. In other wards, IsDirtyEx * entity is NOT fetched: return the value of the normal IsDirty flag * entity is FETCHED; when an entity's field value changes from that of its DB value, return True otherwise its False

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 19-May-2005 16:17:04   

omar wrote:

Greetings, I always thought of an entity's IsDitry as a flag for when any of the entity's fields is changed. The problem is when an entity is loaded from the database (like when loading a collection from the database); in that case also the entity's IsDirty is True.

No, when an entity is loaded from the db, IsDirty is false. This is because the object fetch routine uses ForcedCurrentValueWrite to set the field values, no flags are set.

If you set fields yourself in the InitClass.. method, the fields get dirty. if you don't want that, set the field values using fields(index).ForcedCurrentValueWrite(..)

When does your entity's IsDirty flag become set to true then after a fetch?

What I really need is a flag for when the entity's fields become dirty by assignment (from code or UI) and not by loading from the DB.

That's the task of the IsDirty simple_smile

In other wards, IsDirtyEx * entity is NOT fetched: return the value of the normal IsDirty flag * entity is FETCHED; when an entity's field value changes from that of its DB value, return True otherwise its False

So when the entity is new and you've set a couple of fields, IsDirtyEx should not return true? That's odd I think. IsDirty signals if fields have been changed.

For which scenario do you need this?

Frans Bouma | Lead developer LLBLGen Pro
omar avatar
omar
User
Posts: 569
Joined: 15-Oct-2004
# Posted on: 19-May-2005 19:27:55   

No, when an entity is loaded from the db, IsDirty is false. This is because the object fetch routine uses ForcedCurrentValueWrite to set the field values, no flags are set.

this meens that my code must be setting some fields and hence changing the IsDirty flag. If the IsDirty does NOT change because of load from the DB, then this is exactly what I want. I will invistegate my code to see wehere things are changing.

If you set fields yourself in the InitClass.. method, the fields get dirty. if you don't want that, set the field values using fields(index).ForcedCurrentValueWrite(..)

this is a great tip. There are cases where ForcedCurrentValueWrite can be useful simple_smile