Taking the example from the tutorial - there is an Order Header with Order Items. There are facilities to Add and Delete items, but the Item property of the collection is ReadOnly.
What is the preferred method for editing an item - for example, to change the quantity of the Order Item?
Thanks,
Gary.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The items in a CPersistentColelction are readonly, but the objects they hold are not. What this means is that to add/remove items from the collection you must use the appropriate methods.
However to change an object is pretty simple. To change the quantity (for example) use the following:
I now see what my problem is. When I change an item, it is not marking the parent object as being Dirty. The Add/Remove methods do, but changing the item as above doesn't. The result is that nothing is saved if only the item has been changed.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I'm just wondering if I'm missing something...
Taking the example from the tutorial - there is an Order Header with Order Items. There are facilities to Add and Delete items, but the Item property of the collection is ReadOnly.
What is the preferred method for editing an item - for example, to change the quantity of the Order Item?
Thanks,
Gary.
The items in a CPersistentColelction are readonly, but the objects they hold are not. What this means is that to add/remove items from the collection you must use the appropriate methods.
However to change an object is pretty simple. To change the quantity (for example) use the following:
DirectCast(m_order.OrderLines.Item(0), COrderLine).Quantity = 4
- Richard
Ah - yes.
I now see what my problem is. When I change an item, it is not marking the parent object as being Dirty. The Add/Remove methods do, but changing the item as above doesn't. The result is that nothing is saved if only the item has been changed.
Yes, you are correct. Add/Remove dirties the parent object because the collection itself has changed and therefore the parent must be resaved.
Modifying a single object in the collection won't dirty the parent as the parent object itself doesn't need saving, only the child object does.
- Richard.