SetParent Method

Updates parent and grandparent object references of a child class instance

Namespace:  Microsoft.CommerceServer.Runtime
Assembly:  Microsoft.CommerceServer.Runtime (in Microsoft.CommerceServer.Runtime.dll)

Syntax

'Declaration
Public MustOverride Sub SetParent ( _
    parent As Object _
)
'Usage
Dim instance As MappedStorageBase
Dim parent As Object

instance.SetParent(parent)
public abstract void SetParent(
    Object parent
)
public:
virtual void SetParent(
    Object^ parent
) abstract
public abstract function SetParent(
    parent : Object
)

Parameters

Remarks

SetParent allows an object to fix up any internal references to parents, grandparents, or other fields associated with the surrounding OrderGroup.

This methods typically gets called when performing an Add() operation on a collection, or during conversion of an OrderTemplate to a Microsoft.CommerceServer.Runtime.Orders.Basket or a Basket to a PurchaseOrder.

Classes containing one or more collections should propagate the SetParent call to all members of its collections. The SetParent implementations of the base order system classes perform this step for the collections they contain.

When SetParent is implemented by a base class, a derived class should call the base class version from its override with the same parent provided.

Examples

The following code example is used in a class that has a custom collection, ChildCollection.

using Microsoft.CommerceServer.Runtime;
class MyClassContainedInOrderForm : MappedStorageBase
{
  ChildCollection childCollection;
  public override void SetParent(Object parentObject)
  {
    Debug.Assert(null != parentObject);
    // Perform an explicit cast to parent object type (OrderForm)
    this.parentOrderForm = (OrderForm)parentObject;
    this.orderFormID = this.parentOrderForm.OrderFormID;
    this.orderGroupID = this.parentOrderForm.ParentOrderGroup.OrderGroupID;
    // Progagate this call to contained children in our collection.
    foreach (ChildClass child in this.childCollection)
      child.SetParent(this);
  }
} 

Permissions

See Also

Reference

MappedStorageBase Class

MappedStorageBase Members

Microsoft.CommerceServer.Runtime Namespace

StorageLoadInProgress

SetDirty

SetChildDirty