I have an Id field in my BO that will potentially be used by used by other applications (e.g. SharePoint Business Data Catalog) as a primary key. The idea is to provide a key value that is set 'by hand' and easy to remember (a little bit like CustomerId 'ALFKI').
When a new instance of the BO is created I want all users to be able to fill this field. Once the field has a value only a certain group of people (e.g. Administrators) are allowed to change the field value because this would obviously have an impact on other applications.
What would be a good way to accomplish this ?
We overwrite CanWriteProperty in the BO with something like this:
public override bool CanWriteProperty(string propertyName)
bool canWrite = base.CanWriteProperty(propertyName); //Call base.CanWriteProperty before referencing specific methods in this B.O. to prevent object instantiation when unnecessary
if (canWrite == true)
Rob is right for 2.1-3.8. In CSLA 4 you can create an authorization rule that does what you need - examining the state of the object to decide whether to return true or false.
Copyright (c) Marimer LLC