IsDirty override not firing

IsDirty override not firing

Old forum URL: forums.lhotka.net/forums/t/4837.aspx


wjcomeaux posted on Tuesday, May 13, 2008

Hello:

I am generating CSLA with Codesmith for a web application. I have a form on which I load a Task_ER object. Each task has a collection (Opportunity_ERL). On the webform when I click the Update button I load the Task_ER from the database and update it appropriately.

If I've made changes to any of the Opportunity_EC items they get updated. Finally, if all is valid I call Task_ER.Save().

Before entering the Save function I can see that my Task_ER is dirty (even if it's just the Opportunity_ERL collection (or a single object in the collection) that is dirty. This is the desired behavior. However, once the code goes into the Save function it seems as though my IsDirty overrides are no longer called. instead ONLY the IsDirty decined in BusinessBase is called, which declares my object as clean since it ONLY check local variables and doesn't take into account the extra logic I have in my IsDirty override.

Any ideas why ther base IsDirty is called but never my overridden IsDirty?

Thanks, Will

sergeyb replied on Tuesday, May 13, 2008

Sounds rather strange.  Could you put a breakpoint in your override to see if it is called?  Also, (grasping for straws) is the Opportunity collection declared as NotSerialized by any chance?  This would cause the same symptom after Clone is called.

 

Sergey Barskiy

Senior Consultant

office: 678.405.0687 | mobile: 404.388.1899

cid:_2_0648EA840648E85C001BBCB886257279
Microsoft Worldwide Partner of the Year | Custom Development Solutions, Technical Innovation

 

From: wjcomeaux [mailto:cslanet@lhotka.net]
Sent: Tuesday, May 13, 2008 10:16 AM
To: Sergey Barskiy
Subject: [CSLA .NET] IsDirty override not firing

 

Hello:

I am generating CSLA with Codesmith for a web application. I have a form on which I load a Task_ER object. Each task has a collection (Opportunity_ERL). On the webform when I click the Update button I load the Task_ER from the database and update it appropriately.

If I've made changes to any of the Opportunity_EC items they get updated. Finally, if all is valid I call Task_ER.Save().

Before entering the Save function I can see that my Task_ER is dirty (even if it's just the Opportunity_ERL collection (or a single object in the collection) that is dirty. This is the desired behavior. However, once the code goes into the Save function it seems as though my IsDirty overrides are no longer called. instead ONLY the IsDirty decined in BusinessBase is called, which declares my object as clean since it ONLY check local variables and doesn't take into account the extra logic I have in my IsDirty override.

Any ideas why ther base IsDirty is called but never my overridden IsDirty?

Thanks, Will



wjcomeaux replied on Tuesday, May 13, 2008

Hey Sergey

I have put a breakpoint on my override. That's how I verified that it was never called. If I call Task_ER.IsDirty my breakpoint is hit. Immediately after that if I call Task_ER.Save() my breakpoint is NOT hit but the IsDirty in BusinessBase is.

Nothing is marked as NotSerialized at this time.

Thanks, Will

sergeyb replied on Tuesday, May 13, 2008

Could you check the actual data in your object after you call save to check if you can see the changes your just made to the collection?  My only guess is that Save is called on a different object?...

 

Sergey Barskiy

Senior Consultant

office: 678.405.0687 | mobile: 404.388.1899

cid:_2_0648EA840648E85C001BBCB886257279
Microsoft Worldwide Partner of the Year | Custom Development Solutions, Technical Innovation

 

From: wjcomeaux [mailto:cslanet@lhotka.net]
Sent: Tuesday, May 13, 2008 10:30 AM
To: Sergey Barskiy
Subject: Re: [CSLA .NET] RE: IsDirty override not firing

 

Hey Sergey

I have put a breakpoint on my override. That's how I verified that it was never called. If I call Task_ER.IsDirty my breakpoint is hit. Immediately after that if I call Task_ER.Save() my breakpoint is NOT hit but the IsDirty in BusinessBase is.

Nothing is marked as NotSerialized at this time.

Thanks, Will



wjcomeaux replied on Tuesday, May 13, 2008

I've checked the actual data. If I let the save continue, the additional objects I've added to the child collection are not persisted.

However, if I specifically change a property on the parent object before calling save then everything works as it should.

For now, as a work around I'm calling save on the object collection after adding each child record. Then as a final cleanup I call Save on the Task_ER to commit any changes made there.

It's a hack for now, but it works...

Will

sergeyb replied on Tuesday, May 13, 2008

As long as it works… If you want to post your three classes, I could look at those to see if anything jumps at me…

 

Sergey Barskiy

Senior Consultant

office: 678.405.0687 | mobile: 404.388.1899

cid:_2_0648EA840648E85C001BBCB886257279
Microsoft Worldwide Partner of the Year | Custom Development Solutions, Technical Innovation

 

From: wjcomeaux [mailto:cslanet@lhotka.net]
Sent: Tuesday, May 13, 2008 11:14 AM
To: Sergey Barskiy
Subject: Re: [CSLA .NET] RE: RE: IsDirty override not firing

 

I've checked the actual data. If I let the save continue, the additional objects I've added to the child collection are not persisted.

However, if I specifically change a property on the parent object before calling save then everything works as it should.

For now, as a work around I'm calling save on the object collection after adding each child record. Then as a final cleanup I call Save on the Task_ER to commit any changes made there.

It's a hack for now, but it works...

Will



Copyright (c) Marimer LLC