How can I tell the business object that it's property object has changed?

How can I tell the business object that it's property object has changed?

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


espenrl posted on Friday, January 01, 2010

I have this custom type UserRoles that I use for a property in my business object.

public UserRoles Roles {get; set;}

The above code does not reflect the actual code. I am using a csla managed backing field.

Now, I want my business object marked dirty when properties of the UserRoles object is changed. How can this be achieved?

rxelizondo replied on Saturday, January 02, 2010


Is the UserRoles type derided from BusinessBase? If so, if you are using managed field, I think that what you are asking for is done automatically already. On the other hand, if the UserRoles is not derived from BusinessBase then its a totally different ball game.

You should know that if your UserRoles type inherits from BusinessBase you should remove the "set" accessors from your property declaration, if you don't then you will get all kind of unexpected behaviors.

Come to think about it, when using managed fields, I think the CSLA should raise an error if you try to set the field value of a BusinessBased derived object more than once. This will make it clear that doing that is not a good thing.

JonnyBee replied on Saturday, January 02, 2010

Your UserRoles class should inherit from BusinessBase - and then it will work like magic.

Look at the ProjectTrackercs sample in Csla downloads for how this is done in the custom Principal/Roles object.

ajj3085 replied on Tuesday, January 05, 2010

I would think that your UserRoles class should subclass BusinessListBase.  Then it contains objects which subclass BusinessBase. 

Also, I would think you'd want your Roles property to be private settable.  The UI should be altering the contents of the collection, not replacing the collection itself.

espenrl replied on Tuesday, January 05, 2010

Thanks for all the answers!

I'll have the BusinessBase solution in mind, but I want to keep the UserRoles object small and it's API clean. Is there another way to achieve this? I have tried implementing INotifyPropertyChanged, but that was no success. I guess I'll fire up Reflector and digg into the "magic". :-)

Copyright (c) Marimer LLC