ReadOnly entities

Posts   
 
    
Mountain
User
Posts: 21
Joined: 01-Apr-2005
# Posted on: 01-Apr-2005 05:10:40   

What is the best way to make an entity (including any child entities) entirely readonly? Once an entity is made readonly, how could it then be made readwrite again? Thanks!

P.S. I know about the IsReadOnly property for collections -- I just want to do something similar for a single entity.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39588
Joined: 17-Aug-2003
# Posted on: 01-Apr-2005 10:01:14   

I looked for a solution for this for a while, but the problem is: how to make it read-only without a switch property? I mean: Setting a property to show it's read-only, will not work of course, because setting it to false will make it readwrite again. A wrapper like the ArrayList readonly wrapper could be, but that would require new types I think.

I haven't found a way to solve this properly yet.

Frans Bouma | Lead developer LLBLGen Pro
jeffreygg
User
Posts: 805
Joined: 26-Oct-2003
# Posted on: 01-Apr-2005 11:09:43   

Otis wrote:

I looked for a solution for this for a while, but the problem is: how to make it read-only without a switch property? I mean: Setting a property to show it's read-only, will not work of course, because setting it to false will make it readwrite again. A wrapper like the ArrayList readonly wrapper could be, but that would require new types I think.

I haven't found a way to solve this properly yet.

Hmmm...how about Decorator? Create a read-only entity that wraps the read/write entity but only allows read access. This might prove problematic in terms of collections, relations, etc, but this could be a bullet-proof method of controlling access...admittedly on a chunky, entity-level basis.

Just re-reading your post...I think this is what you're referring to with the ArrayList readonly wrapper...

Jeff...

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39588
Joined: 17-Aug-2003
# Posted on: 01-Apr-2005 11:47:34   

Yes, the decorator pattern indeed simple_smile

It's not easily implemented I think. I could make an internal constructor which sets a readonly flag and accepts a fields object, setting flags on related objects as well, but it is cumbersome to propagate it through to all the fields and make sure there is no way to write a value into any field.

Frans Bouma | Lead developer LLBLGen Pro
rsiera
User
Posts: 48
Joined: 09-Oct-2011
# Posted on: 08-Aug-2021 11:14:20   

Has anything changed on this topic in the last 15 years ? Having immutable entities would indeed help to strengthen my code. Making the entity read/write again is not a requirement for me. I would just refetch it, if I needed a mutable entity.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39588
Joined: 17-Aug-2003
# Posted on: 09-Aug-2021 09:14:52   

See the entity field mappings tab in the entity editor: https://www.llblgen.com/Documentation/5.8/Designer/Functionality%20Reference/EntityEditor_FieldMappingsTab.htm You can specify the actions allowed on an entity there, e.g. read / delete, read, etc.

Frans Bouma | Lead developer LLBLGen Pro