CSLA .NET

From Rockford Lhotka's Expert C# 2008 and VB 2008 Business Objects books

ChildDataPortal objectfactory

rated by 0 users
This post has 8 Replies | 1 Follower

Top 25 Contributor
Posts 247
rfcdejong Posted: Wed, Dec 10 2008 6:36 AM

I see that only the DataPortal can make use of the Objectfactory.

The ChildDataPortal doesn't know about any Objectfactory?
Methods are called on the business object self: Child_Create, Child_Fetch, Child_Insert, Child_Update, Child_DeleteSelf

I tried to fetch child data and ran into this issue, maybe by design. But it means that an child can't get it's own data? Calling DataPortal.FetchChild won't work with the Objectfactory.

Please more details :)

Top 10 Contributor
Posts 6,297

ObjectFactory is discussed in the Expert C# 2008 Business Objects book that should be available any day now.

I also provide some good discussion of ObjectFactory on my blog at www.lhotka.net/weblog.

 

Rocky

Top 10 Contributor
Posts 3,598
Andy replied on Wed, Dec 10 2008 12:14 PM
Amazon is telling me my order should ship on 12/26, if that helps anyone...
Top 200 Contributor
Posts 35
FrankM replied on Fri, Dec 12 2008 2:34 PM
We got the e-book already, but still can't figure out how to update children in this new ObjectFactory of Root BO.

In the classic DataPortal way, we could call FieldManager.UpdateChildren(this) in RootBO.DataPortal_Update().

Now in this separated ObjectFactory, how can we update children in the similar way? The FieldManager is protected.
Top 10 Contributor
Posts 6,297

The object factory model TOTALLY DELEGATES ALL RESPONSIBILITY TO THE FACTORY OBJECT.

 

In other words, you can load your child objects however you’d like – it isn’t CSLA’s responsibility any longer.

 

The ultimate goal of ObjectFactory is to allow an ORM (specifically some future version of ADO.NET EF) to totally create and populate your object graph from the database. In that case the ORM would create the child objects and load them with data. How will that work? That depends on what Microsoft ultimately does with EF – and the answer is unknown today.

 

Ignoring EF, the short answer is that you need to devise your own interface or technique for how your factory object will interact with your business objects. I intentionally didn’t solve that problem, because there are numerous possible solutions – each with pros and cons – and until I know where EF is going I can’t effectively choose between them.

 

In Chapter 18 I discuss a number of data access solutions and techniques – and that’s not even an exhaustive list, just the highlights. If I picked any one of them as the exclusive way to do persistence I’d piss off more people than I’d make happy.

 

I certainly don’t see ObjectFactory as the ultimate replacement for the normal data portal behavior. The normal data portal behavior is far simpler to code, and is probably preferable for most scenarios.

 

However, like I said in another thread, as time goes on it may be that some specific pattern emerges that is clearly the “right way” to use the object factory, and if that happens I may make CSLA directly support that pattern – as long as it doesn’t interfere with the primary goal of supporting some future version of EF.

 

Rocky

Rocky

Top 200 Contributor
Posts 35
FrankM replied on Fri, Dec 12 2008 4:10 PM
I exposed the FieldManager in my BaseBO, then problem fixed.
ObjectFactory is great!  Please add more features like this in the future to make CSLA more open.
Top 25 Contributor
Posts 247
rfcdejong replied on Wed, Dec 17 2008 3:13 PM
The ObjectFactory looks like the only way of seperating data access from the business. But still that the business object should be able to use "lazy loading" childeren when needed. Just by checking if the child property is loaded or not.

Anyway, we're playing with CSLA to see if the pros are winning against the cons, my company is going to buy the book (they said 3 weeks ago) :)
Top 200 Contributor
Posts 35
FrankM replied on Wed, Dec 17 2008 6:27 PM
Does this mean "don't use objectFactory to lazy-load child" until the "right way" appear?
Top 25 Contributor
Posts 247
rfcdejong replied on Fri, Dec 19 2008 2:02 AM
I have no idea, lazy loading works with just another objectfactory for the child. I rather didn't test it yet if it works the other way around, persisting it to a storage.
Page 1 of 1 (9 items) | RSS

Please contact Magenic for your .NET consulting
and CSLA .NET mentoring needs.
Please consider making a donation to help support the ongoing development of CSLA .NET.

Make donation through PayPal - it's fast, free and secure!
Why donate?
Copyright (c) 2006-2010 Marimer LLC. All rights reserved.
Email admin@lhotka.net for support.
Powered by Community Server (Non-Commercial Edition), by Telligent Systems