Question on Parent-Child Business Obejct design

Question on Parent-Child Business Obejct design

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


GPhillips posted on Wednesday, April 25, 2007

Is there a recommended method to set up Parent Child Business object relationships when there are A LOT of children.  I would like a collection of children in the parent, but if there are 500-600 children, I don't want to load them when I get the parent and then cart them around, especially if I don't need them.  Specifically, I have an Order-Detail scenerio but most orders can have several hundred details. The optimal solution would be to have the collection property but not populate it unless we needed something from it, but I don't see an easy way to do that without losing CSLA functionality

Also, it would be nice to have a collection of Orders within each Customer.  Yikes..

Any suggestions would be appreciated.  This is my first project with CSLA so if I'm asking something that is covered in the book, a point in the right direction would be appreciated.

ajj3085 replied on Thursday, April 26, 2007

Are you hitting performance issues with loading 500 child objects?  Normally, I would say you likely would make the children root objects themselves, but in an order-detail, that doesn't make sense.  I'm assuming by detail you mean the line items on the order.

You can lazy load the collection and not lose functionality, but if you bind a gird to the items, that will cause a load. 

I don't think you'd want a collection of orders with each customer.  I would think you have an OrderInfo object, which is contained in a CustomerOrders ROL object.  The OrderInfo wouldn't load all the line items, but may provide summary information.  If you need the details of an order, you could at that point load the full order object.  I assume your use case doesn't allow for viewing the details of all orders for a customer all at the same time, correct?

HTH
Andy

GPhillips replied on Thursday, April 26, 2007

Andy,

Thanks for the reply.  I'm not sure what you mean by "lazy load".  I have considered having the detail collection property in the Order, but not popluating it until it was needed and maybe pulling down a count of them from the DB when the Order is loaded.  I would have to fiddle with the dirty properties and add code so a Save of the order would not need the details.  The idea of creating Info objects in addition to the full object doesn't appeal.

The performance issue is a concern considering that if the order were passed to a server and back it would have to serialize and deserialize all the details every time.

Is "ROL" RootObjectList?  Sort of like a pick list for the Orders filtered by Customer?

Thanks

Gary

 

ajj3085 replied on Thursday, April 26, 2007

By lazy load, I mean that details won't be loaded until the first time the details property on order is accessed.

public OrderDetails Details { get { if ( details == null ) { details = OrderDetails.Get(); } return details; }

The reason I suggested readonly objects is because they would be supporting a different use case; displaying order line details, not editing them.  ROL is read only list, something that inherits ReadOnlyListBase.

Copyright (c) Marimer LLC