Save Not Setting IsNew or IsDirty to false

Save Not Setting IsNew or IsDirty to false

Old forum URL:

shaselsc posted on Thursday, January 13, 2011

I'm very new to CSLA and this is my first project trying to implement the framework. I have a simple class that's an EditableRoot that has a few basic properties. I did not override the Save method, but I did override the DataPortal_Insert and DataPortal_Update methods. I was just running a set of tests on the object to make sure everything worked ok. Here's the code for it:

m_decal = Decal.NewDecal();
m_decal.DecalTypeCode = 'S';
m_decal.PrintInsertDate = null;
m_decal.PrintLabelDate = "01/14/2011";
m_decal.PrintInsertDate = "01/14/2011";

I expected the second Save to run the DataPortal_Update(), but it ran the Insert again. I checked the IsDirty and IsNew properties after the first Save and saw that they were still set to true. I then put in MarkOld() at the end of my DataPortal_Insert() function to try and get different results, but with no success. I'm using CSLA if that helps.

Also, if anyone has any easy tips or tricks on how to make my posts look better without going into the html, I'd appreciate that too.


tmg4340 replied on Thursday, January 13, 2011

The "Save" method returns a new object, which you need to hook up to your reference.  So your calls should look like this:

m_decal = m_decal.Save()

The returned object will have the updated IsDirty, IsNew, etc. values in it.

Can't help you with the post formatting - going into the HTML is the only way I've found to get certain things done.


- Scott

shaselsc replied on Thursday, January 13, 2011

Sadly, I knew that and just completely forgot. Thanks for the help Scott!

Copyright (c) Marimer LLC