CurrentOrder is root BusinessBase<Order>, OrderItems is child collection BusinessListBase< OrderItemList, OrderItem >
I want to delete a OrderItem, but it still sits in database. Pls help.
CurrentOrder.OrderItems.Remove(CurrentOrderItem);
CurrentOrder = CurrentOrder.Save();
I track the code and find the removed orderItem is not included here:
private static void Update_OrderItem(ref Order item)
{
foreach (OrderItem itemToUpdate in item.OrderItems)
{
itemToUpdate.OrderNo = item.OrderNo;
new OrderItemFactory().Update(itemToUpdate, true);
}
}
I read the sample and find a solution:
internal void Update(Order order)
{
var factory = new OrderItemFactory();
var deletedlist = GetDeletedList<OrderItem>(order.OrderItems);
if (deletedlist.Count > 0)
{
foreach (var obj in deletedlist)
{
factory.Update(obj);
}
}
foreach (var obj in order.OrderItems)
{
factory.Update(obj);
}
}
If you are using a current version of CSLA (3.6 and higher) then you don't need to worry about this sort of thing. The child data portal functionality handles these details for you.
Copyright (c) Marimer LLC