Data Object Set Dirty Conundrum  
Author Message
Wee Bubba





PostPosted: Architecture General, Data Object Set Dirty Conundrum Top

i am setting properties in my DAL objects like this:

set { ... if value is different then set _isDirty to true }

then i am only hitting the database for data objects that are dirty.

this works fine for simple types but for reference objects (e.g. generic lists) it is possible for a user of my object to alter the state of the object without triggering my dirty flag. e.g.

List<string> myList = dataObject.MyList;

myList.Add("Hello World");

is my dirty architecture all wrong or is there a simple solution for this. thanks.



Architecture1  
 
 
RMD





PostPosted: Architecture General, Data Object Set Dirty Conundrum Top

You'll need to either expose your lists as indexers on your parent objects (thereby allowing you to monitor state changes) or you'll need to create custom collection classes (MUCH easier in .NET 2.0 than in 1.x, thankfully) which can then report to their parent object via events.

Both ways are valid, although the custom collection classes one is a bit cleaner.