New Stereotypes in Csla 3.5 and up - what's the ReadOnlyList issue

New Stereotypes in Csla 3.5 and up - what's the ReadOnlyList issue

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


tiago posted on Monday, September 14, 2009

Hi Rocky,

Since Csla 2.0 we were presented to a lot of new members of the Csla Stereotypes family.

First came DynamicRoot and DynamicRootList (aka ERLB). They arrived on a boat named Csla 2.1

The next boat - Csla 3.0 - didn't bring in any new members.

Then a big ship arrived - Csla 3.5 and we saw two departures, four arrivals and two renamings.

Back to the topic, I read a lot of times that a ReadOnlyList (root or child) can contain EditableChild objects.

In August 2007 on I Am Working On My Using CSLA NET 30 Ebook And Wrote Some Content That I Don't Think I'm Going To Use In The Book http://www.lhotka.net/weblog/IAmWorkingOnMyUsingCSLANET30EbookAndWroteSomeContentThatIDontThinkImGoingToUseInTheBook.aspx is a very useful example of changing a ReadOnly object by setting IsReadOnly to false, changing whatever was needed and reseting IsReadOnly to true.

The point is:
If my ReadOnlyList (root or child) contains an EditableChild, is there a way to save the EditableChild?

RockfordLhotka replied on Monday, September 14, 2009

There is no way to save a read-only object - that makes no sense as it is read-only.

The example of altering a read-only object or list was to illustrate that it is possible to update cached "read-only" data without reloading the object(s) from the database.

But that's really a narrow scenario where you have cached read-only data that you know is stale, and which you can (at least partially) update for known changes made by an editable object.

Even this is not necessarily all that useful, at least not in a multi-user environment, since the underlying data could have been edited by other users too, and the cache becomes rapidly invalid. But in a single-user environment where the cached list is relatively large, it can be worth the effort of updating the cache without reloading from the database.

tiago replied on Tuesday, September 15, 2009

RockfordLhotka:
There is no way to save a read-only object - that makes no sense as it is read-only.

I couldn't agree more. I'm rewriting some codegen templates and I think the templates should check that the stereotypes used in a parent/child relationship make sense.

Copyright (c) Marimer LLC