Retrieving Target Object Collections
Object collections can be retrieved at both the COM and Automation level.
Retrieving Object Collections Using Automation Interfaces
To retrieve a relationship, first declare a variable as an object that implements the ITargetObjectCol interface. Next, set the variable equal to the object member that is the collection you want to retrieve.
Note All collections in a Microsoft® SQL Server™ 2000 Meta Data Services repository are attached to repository objects as members.
For example, the following Microsoft Visual Basic® code retrieves a collection of bugs (a target object collection) discovered by a particular person into the variable called BugCollection:
DIM BugCollection As ITargetObjectCol
DIM Person As RepositoryObject
REM Retrieve the source object into the Person variable
Set BugCollection = Person.bugs
In this example, BugCollection(1) can refer to the first object in the collection.
Retrieving Relationship Collections Using COM Interfaces
To retrieve a relationship, you can perform the following steps:
- Call the Invoke method of the interface to which the collection is attached.
- Pass in DISPATCH_PROPERTYGET to specify that this is a property-get operation.
- Pass in the dispatch identifier for the collection to be retrieved.
- The Invoke method will pass an IDispatch interface pointer for the collection back to you.
- Invoke the QueryInterface method of the IDispatch interface to retrieve an ITargetObjectCol interface pointer for the collection of target objects.