Confusion over Editable collections - Source + screenshots provided

Confusion over Editable collections - Source + screenshots provided

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


sroberts posted on Friday, February 27, 2009

I must admit I've just hit pretty much the same problem and I think the books don't quite give a full enough example on how to impliment a certain type of editable root list, it's either that or I can't see the wood for the tree's.

My situation is that I need to be able to retrieve and then save a collection of 'note' objects, but as a batch, I don't want the instant save that an EditableRootListBase offer.

So I'm using a BusinessListBase class (Notes) and a BusinessBase class (Note)

Below are links to the source code for these two classes (couldn't see how to attach more than 1 file to a post here, hence they're hosted on my website)

Notes.vb
Note.vb

And here is a screenshot of my application with an error I recieve when attempting to call Notes.Save

I'm sure I'm missing some simple update/insert methods on either Notes or Note, but I've gone round in circles trying different combinations of DataPortal_xxx and Child_xxx methods and just can't seem to get it to work.

I also currently get an error about edit level mismatch when I call .Cancel changes to the Notes BO (via a bound CSLA Binding Source Node helper object)


ajj3085 replied on Friday, February 27, 2009

In your Notes class you need to override DataPortal_Update.  In your DP_U, using the ConnectionManager to open a single connection, then call MyBase.Child_Update. 

sroberts replied on Saturday, February 28, 2009

Thanks for your help ajj, that's sorted it. I can't believe I missed such a simple thing, I should have known that the parent needed to initialise the update of it's children, but I assumed the framework would just handle it, given that I didn't actually have a managed field for the children and hence no fieldmanager.

Just out of morbid curiousity, do you know where in the pdf/paper books this technique is mentioned ?

ajj3085 replied on Monday, March 02, 2009

Well I thought this as well.. but if you really think about it, there's no way it could work.  The root has to open the connection... and as Rocky explained it can't possible know how to do that in this case.  So you need to override something.  

It's in the book somewhere, I can't remember.  If you search the forums though I think Joe found it for me, because I asked the same question.   Smile [:)]

Copyright (c) Marimer LLC