ChildDataPortal objectfactory

ChildDataPortal objectfactory

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


rfcdejong posted on Wednesday, December 10, 2008

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 :)

RockfordLhotka replied on Wednesday, December 10, 2008

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.

 

ajj3085 replied on Wednesday, December 10, 2008

Amazon is telling me my order should ship on 12/26, if that helps anyone...

FrankM replied on Friday, December 12, 2008

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.

RockfordLhotka replied on Friday, December 12, 2008

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

FrankM replied on Friday, December 12, 2008

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.

rfcdejong replied on Wednesday, December 17, 2008

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) :)

FrankM replied on Wednesday, December 17, 2008

Does this mean "don't use objectFactory to lazy-load child" until the "right way" appear?

rfcdejong replied on Friday, December 19, 2008

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.

Copyright (c) Marimer LLC