Editable Root List

Editable Root List

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


Helen W posted on Tuesday, May 16, 2006

I have a requirement to use an Editable Root List. I am finding that it errors out in BusinessBase at:

internal void SetParent(Core.IEditableCollection parent)

{

   if (!IsChild)

      throw new InvalidOperationException(Resources.ParentSetException);

   _parent = parent;

}

because IsChild is false for a root object, so it raises an exception before setting the parent. Is there a recommended fix for this? Or am I missing something (highly likely!)

Thanks a bundle,

Helen

xal replied on Tuesday, May 16, 2006

You should be calling MarkAsChild() inside the fetch method...

 

Andrés

Helen W replied on Tuesday, May 16, 2006

You're right!

Thanks a lot,

Helen

malloc1024 replied on Thursday, May 18, 2006

Helen,
I would highly recommend that you read the book.  It is well worth it.  It explains the framework in detail.

Helen W replied on Thursday, May 18, 2006

I've got the book and I have read most of it at least one time. Now I am painstakingly converting a small project to use the framework, with the intention of using it for most of my future development. My "small" project is sufficiently different from the Tracking project that it is not as easy to convert (for someone not completely familiar with the CSLA) as I might have hoped. But it's going well. Thanks for your patience.

Cheers,

Helen

MikeHamilton replied on Friday, October 27, 2006

Helen,

New member here, just doing some seaching before asking a question or two, and wanted to let you know I am in the same boat as you.

I bought the PDF version of the book from the publisher's site, and have it open on one monitor while trying to write first application using CSLA. SO I am not completely familiar with CSLA framework, or complete OO practice (been using pseduo object methodolgy)

Mike

 

Helen W replied on Thursday, May 18, 2006

Quick question for you -- is the semantic meaning of the "IsChild" property that the item is a member of a collection of BOs?

thx

Helen

xal replied on Thursday, May 18, 2006

Helen,
Well, yeah, it means that it's a child of another object (collection or not).
BusinessListBase doesn't not allow adding items that are not marked as child...

It also implicates that you cannot save that item directly.... (You can't call the save() method on the child).
The reason is that you generally want your child items to be saved in the context of it's parent object (probably inside a transaction started by it). That way if a child item fails to save, then nothing is persisted and you preserve integrity of the data.

It's also a good idea to call MarkAsChild on child items even when they're not part of a collection. For example when you have EditableRoot -> Child (whithout an intermadiate collection, which makes it a 1 to 1 relation). The reasons are the same as with collections...

Andrés

Copyright (c) Marimer LLC