In Chapter 5 of your C# 2008 Business Objects book, you state that "The BusinessListBase class includes a default implementation of the DataPortal_Update() method, which loops through all child objects (and deleted child objects) to ensure the appropriate Child_XYZ method is called on each when the collection is being saved."
Yet, when i look at the code in the BusinessListBase class, all I see is a NotSupportedException being thrown in DataPortal_Update.
Furthermore, you implemented within your Roles class in ProjectTracker similiar code that simply turns around and fires the Child_Update() method.
This omission means that we need to implement in each of our own BusinessListBase objects the desired behavior of calling the Child_Update method manually, correct? This assumes that we actually want to allow edits on the BusinessListBase children to be saved.
Please tell me if I am missing something here...
Thanks Rocky!
One quick question though, with the connection pooling that you provide using your ConnectionManager, wouldn't we be able to delegate the connection string down into the Child_Update portion, thuse allowing the DataPortal_Update method to have a default implementation that calls the Child_Update?
I do not know if this makes sense at all...just thinking.
If the BLB is a root object, then there’s no pre-existing
connection. It is always the root object’s job to open/close the
connection – and that’s something CSLA can’t do for you.
If the BLB is a child object (so it is owned by some other root
object), then you have to implement nothing in the collection, because its
parent will have triggered the Child_Update() method by calling either the
FieldManager or DataPortal methods to trigger child updates. Of course in this
case that other root object has the responsibility to open/close the
connection.
Rocky
From: DCottle
[mailto:cslanet@lhotka.net]
Sent: Tuesday, January 27, 2009 10:53 AM
To: rocky@lhotka.net
Subject: Re: [CSLA .NET] Default Implementation of
BusinessListBase.DataPortal_Update() - doesn't coorespond with book.
Thanks Rocky!
One quick question though, with the connection pooling that you provide
using your ConnectionManager, wouldn't we be able to delegate the connection
string down into the Child_Update portion, thuse allowing the DataPortal_Update
method to have a default implementation that calls the Child_Update?
I do not know if this makes sense at all...just thinking.
RockfordLhotka:You do need to implement DataPortal_Update(), because it is your responsibility to open the appropriate database connection (or whatever) so the child objects can be updated.
In a root BLB you should be able to call Child_Update() to
trigger the updates:
protected override void DataPortal_Update()
{
// open db connection
Child_Update();
// close db connection
}
Rocky
From: ajj3085
[mailto:cslanet@lhotka.net]
Sent: Monday, February 02, 2009 10:22 AM
To: rocky@lhotka.net
Subject: Re: [CSLA .NET] Default Implementation of
BusinessListBase.DataPortal_Update() - doesn't coorespond with book.
RockfordLhotka:
You do need to implement DataPortal_Update(), because it is your responsibility to open the appropriate database connection (or whatever) so the child objects can be updated.
I have a question regarding this. In BB, you can call
FieldManager.UpdateChildren( params[] ) to update the children. For a
root BLB, there's no FieldManager property. Do you have to manually loop
through and call DataPortal.UpdateChild for each instance in the list?
The Csla.Data "manager" types exist to help you reuse the same connection for all your objects. This is a technique you can use with System.Transactions.TransactionScope transactions to avoid having TransactionScope use the DTC.
So yes, the idea is to avoid unnecessary use of an expensive distributed transaction.
Copyright (c) Marimer LLC