Pattern for Delete child BLB.Remove(BB)

Pattern for Delete child BLB.Remove(BB)

Old forum URL:

Imker posted on Friday, March 19, 2010

I have a Customer which is a BusinessBase (BB) Object.

The Customer contains a BusinessListBase (BLB) Orders, made from BB Order objects.

Then I want to remove/delete one order from this list.


then I save the customer to persist the change to the database.

customerx = customerx.Save();

As it's an existing customer, the DataPortal_Update() in BB Customer gets called.

After updating the Customer,  I do a FieldManager.UpdateChildren(this);

But the result is a call to Child_DeleteSelf(Customer parent)

When I use FieldManager.UpdateChildren()  Child_DeleteSelf(Order x) gets called

but the Order x is null.


Question: So, how do I persist the delete to the database without knowing the delete Order?

Must I code something in the BLB, or from where do I get the deleted order to properly

delete the order from the database?


I browsed different sections about parent / child behaviour in "Expert C# 2008 Business Objects",

but it seems that I'm somehow missing the point.


Sorry for the basic question.





ajj3085 replied on Friday, March 19, 2010

I think something is off on your design.  I would think that Orders can be edited outside the scope of any customer edit, so any Orders off your customer should represent a LINK to an order, not an actual order.   Is the only way to edit an order really to open the customer for editing?  If it is, your Order object should have enough information (except maybe the Customer Id, which it could get for the first call where you pass Customer to UpdateChildren.

Imker replied on Friday, March 19, 2010

thanks, that was eye opening. made my day, and now, weekend.

The design is a bit off, but it is correct, the order can only be deleted from inside the customer.

I was concentrating on the parameter that comes into Child_DeleteSelf.

But as the Child_DeleteSelf is a method of the child Order, the Order already has it's ID, so YES, the Order has enough information

to delete itself. shame on me. 

Thanks for your patient and inspiring answer.

ajj3085 replied on Friday, March 19, 2010

If the order can ONLY deleted by opening the customer information for editing, then your design is fine.  You design reflects your business requirements, so you're good to go.  Its not my place to say your requirements are wrong.  Smile

Copyright (c) Marimer LLC