Can I lock some child objects as readonly?

Can I lock some child objects as readonly?

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


c_manboy posted on Monday, May 03, 2010

Is there an easy way of locking some child BusinessBase objects to be read only based on if a property is empty or not?

I'm suspecting i may need to use some authorization rules...?  Or is there a hidden "IsReadOnly" base property?

This was probably covered in the book, but i've been on a 72 hour CSLA binge and I dont remember some of these "little" things.

Thanks in advance.

Marjon1 replied on Monday, May 03, 2010

You can always override CanWriteProperty() to return false when you want to prevent editing of fields on the given record.

If you want to prevent adding / removing of items from a list that involves a bit more work and depends on how you interact with GUI (grids, etc).

c_manboy replied on Monday, May 03, 2010

Yes, that makes sense and seems simple enough to implement.   To prevent removing the child items which meet specific criteria couldn't I just do an if...then in a public remove method on the businesslistbase object? 

I know that I asked for an "easy" way...but would the recommended way be to use authorization rules to specify roles which can edit and delete based on a property value?

Troncho replied on Saturday, December 01, 2012

On your derived BusinessListBase class, you can override RemoveItem(..) like this:

protected override void RemoveItem(int index)
{
	if ([condition is met])
		base.RemoveItem(index);
}

Troncho

tiago replied on Sunday, December 02, 2012

It would be nice to have some sort of BusinessRule to accept or reject adding and removing items from a BusinessListBase

Copyright (c) Marimer LLC