LoadProperty: why it set my object as Dirty?

LoadProperty: why it set my object as Dirty?

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

idroesse posted on Friday, January 29, 2010

Is there a way to set a property value (even using LoadProperty) without set IsDirty flag to true?

My pourpose is to create an object, let's call it "ObjectA", use LoadProperty method to assign a new object to property "MyProperty" and then, when user will need it, assign to "MyProperty" the new value, without make Dirty my "ObjectA".
Is it possible?

Thanks in advance.

Peran replied on Friday, January 29, 2010

I'm not sure when in your object lifecycle you are trying to do this but it may help to know that MarkClean() (private method) resets the dirty flag to false.


idroesse replied on Friday, January 29, 2010

Hi, thank you for helping me, but the MarkClean() method doesn't work...

This is what I do:
1. Create "ObjectA", and set "MyProperty" value to a new instance of "MyProperty type";
2. When the user execute a method in "ObjectA" I replace "MyProperty valye" with a new object
3. Execute MarckClean() method on ObjectA.

My problem is now, because ObjectA is still Dirty! I don't know why, but it is...


ajj3085 replied on Friday, January 29, 2010

Is the value you're putting in MyProperty a BusinessBase object?  If it is, and you're creating it new, it will be dirty as well.  Calling MarkClean on ObjectA will change the dirty state of ObjectA.. but not its child object (if that's what you have).

idroesse replied on Monday, February 01, 2010

Hi guys.. I solve the problem and it was my fault! I didn't use DataPortal.FetchChild to populate MyProperty.. Now, when I put data into MyProperty using LoadProperty object is not dirty!!!
I'm feeling as newbie!!

Thanks to all

Copyright (c) Marimer LLC