CSLA .NET

From Rockford Lhotka's Expert C# 2005 and VB 2005 Business Objects books

Welcome to CSLA .NET Sign in | Join | Help
in Search

IsDirty override not firing

Last post 05-13-2008, 10:16 AM by sergeyb. 5 replies.
Sort Posts: Previous Next
  •  05-13-2008, 9:15 AM 23533

    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

  •  05-13-2008, 9:21 AM 23534 in reply to 23533

    RE: IsDirty override not firing

    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



  •  05-13-2008, 9:29 AM 23535 in reply to 23534

    Re: 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

  •  05-13-2008, 9:40 AM 23536 in reply to 23535

    RE: RE: IsDirty override not firing

    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



  •  05-13-2008, 10:13 AM 23537 in reply to 23536

    Re: 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

  •  05-13-2008, 10:16 AM 23538 in reply to 23537

    RE: RE: RE: IsDirty override not firing

    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



View as RSS news feed in XML

Please contact Magenic for your .NET consulting and CSLA .NET mentoring needs.
Please consider making a donation to help support the ongoing development of CSLA .NET.

Make donation through PayPal - it's fast, free and secure!
Why donate?
Powered by Community Server, by Telligent Systems