Retaining Workspace Context

As you move among the objects present in the workspace, Repository automatically retains the context for you. In other words, if you retrieve an item from a relationship collection or a target object collection, the retrieved target item has the same context as the context of the relationship's source item.

However, only relationship collections and target-object collections retain workspace context. If you retrieve an item from any VersionCol object, the reference that Repository returns to you has the context of the open Repository instance in which you are operating. The object reference does not have an in-workspace context.

For example, suppose that within the context of a workspace, you have a reference to the root object. Then you perform these steps:

  1. From the root object, you move to a particular Repository object.

    As you move to each object along the navigation path, Repository returns to you whichever object version is present in the workspace. At each step, the reference that Repository returns preserves the workspace context.

  2. At some point along the navigation path, you materialize an object version's PredecessorVersions collection. Then you retrieve the first item in that collection.

    Repository returns a reference to the oldest predecessor of the object version. Because the PredecessorVersions collection is a VersionCol object (not a relationship collection or a target-object collection), this reference does not preserve the workspace context. All subsequent manipulations of this object (and all subsequent navigations from this object) occur within the general context of the open Repository instance.