Dear Developer Community,
Im looking for a design pattern or best practice to solve the following problem:
I have my business objects (such as Account, Client, Complaint etc) all derived from a BusinessObject base class. These business objects might also consume other business objects, such as Account containing a List<AccountContact>, or Complaint having List<Comments>.
What Im looking for is a mechanism of probing a business object for changes. Something like:
Account acc = new Account();
acc.CompanyName = "New Company";
if (acc.HasObjectChanged) MessageBox.Show("Object Changed!")
else MessageBox.Show("Didnt change yet!");
Any suggestions
Kind regards,
Marcel

Design Patterns: A patern for detecting business object changes needed
Bruce Baker
My base business object class manages an EntityStatus flag to define whether the data is an insert, update, delete, or unchanged. When the object property is set, the set method calls the base class EntityStateChanged to define the appropriate state.
Hope this helps...
sql2000_2005
xlordt
skuehner
Peter,
I considered all the mentioned options but I think I want to go with the Observer patern you mentioned. So after some research, I found that it could be implemented in C# with the Event-Listner patern.
Can you give me some guidance towards implementing it in my design then. You see, I dont think I totally understand the model.
How would the event be registered if I wanted to know whether an AccountContact object changed in the following code:
public class Account : BusinessObject{
List<AccountContact> contacts;
}
Thank you for your time.
Marcel