Editable list of Read only objects

Editable list of Read only objects

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


madonato posted on Wednesday, March 12, 2008

I have a situation where I have an object CourseInfo which inherits from ReadOnlyBase.  I am trying to create an editable list or collection of these objects. In other words, I want to be able to create custom lists of CourseInfo objects that I can add and remove items from.  However, the actual courseinfo object should not be editable. 

My problem is that when I try to create the list with an EditableRootCollection or an EditableRootList it wants the base object of the list (CourseInfo) to be editable.   When I inherit from the ReadOnlyCollection or the ReadOnlyRootList, I cannot modify the contents of the list. I understand that each of objects are supposed to be in charge of saving themselves when you update a list.  I'm new at trying to implement this framework and I was just wondering what kind of object I should use.

Thanks!

mtagliaf replied on Wednesday, March 12, 2008

You need a new CourseInfo object that's read/write (BusinessBase).  The properties on it can all be readonly, except for maybe the integer Position within the list.

When you go to save this object to the DB, you're not actually saving any data to the CourseInfo table, you're saving to the "which courses belong to which lists" tables. 

Since this is a new behavior, you need a new class.


madonato replied on Wednesday, March 12, 2008

That makes sense. Thank you!

Copyright (c) Marimer LLC