Hi :
I have a 3 level object hierarchy as follows :
Object Type Property ClassName BaseType
Root Class - Invoice CSLA BusinessBase
ChildCollection InvoiceLineItems InvoiceLineItems CSLA BusinessListBase
Child InvoiceLineItem InvoiceLineItem CSLA BusinessBase
GrandChildCollection InvoiceSubLineItems InvoiceLineItems CSLA BusinessListBase
GrandChild InvoiceSubLineItem InvoiceLineItem CSLA BusinessBase
The root class data fetch pulls the full dataset fot the object graph, populating the hierarchy by making a function call of
InvoiceLineItems=InvoiceLineItems.GetList(data).
I can see using debug that InvoiceLineItems (when examined from within the child collection instance) correctly populates the data, and has a complete hierarchy to pass back to the root Invoice instance.
However, the returned object in the Invoice instance is being stripped of the InvoiceSubLineItems (grandchild objects) in the returned InvoiceLineItems collection!
Appreciate if anyone has any idea why this may be happening. I'm fairly new to CSLA and OOP programming generally so may be missing something basic.
Fyi, am using CSLA version 3.5 with VB. Have also noticed in debug that the collections exhibit the Count={System.TypeLoadException} exception. This occurs for collections whether they are populated ok or not so may not be relevant (have seen other references to this exception in other threads)
InvoiceLineItem is not subclassed. The child and grandchild are the same class i.e. InvoiceLineItem. The collections InvoiceLineItems and InvoiceSubLineItems are also not subclassed, both are the InvoiceLineItems class.
The way the code is working is as follows:-
InvoiceLineItem has a property of ParentLineItemID and collection property of SubLineItems.
1. The root class calls the GetInvoiceLineItems(data) function
2. InvoiceLineItems creates a collection of all InvoiceLineItems.
3, InvoiceLineItems iterates through the created collection, moving a line item into the relevant InvoiceLineItem.SubItems collections as appropriate depending on the InvoiceLineItem.ParentLineItemID value.
As mentioned, after processing, the InvoiceLineItems collection is as expected with the hierarchial structure when viewed from with the InvoiceLineItems collection at the point of returning itself to the root object. However, the returned collection when examined in the root class is missing all the grandchild items!
Fyi, I've worked around this for my immediate need by having the root class (Invoice) create the hierarchy from the returned InvoiceLineItems collection. This seems to be working ok. However, I'm at odds to understand why the grandchild items are being stripped away duriing the function return call.
Incidentally, I also tried creating the SubLineItem and SubLineItems as totally separate classes i.e. a ReadOnlyBase and ReadOnlyListBase respectively. However, I got the same result i.e. the ReadOnlyBase grandchild items were missing on the returned collection.
Appreciate you're input or any other explanations for this behaviour.
Fyi, thought about using the composite pattern, but decided against it in the immediate term as I've not had the experience of implemeting it and felt that the LineItems in current use case are essentially identical except for hirarchial structure.
Copyright (c) Marimer LLC