This should look pretty straightforward for anyone that has been using the SDK for a while. First we get the management pack elements like the MP itself, the Company and Site classes, the relationship, and the type projection.
Then we use those to create CreatableEnterpriseManagementObjects for the company and the site. In this case I am just generating a random GUID as the ID. We’ll then later use that GUID to look up the Company.
Once we have CreatableEnterpriseManagementObjects in memory and a CreatableEnterpriseManagementRelationshipObject we just need to dump those into a IncrementalDiscoveryData bucket and .Commit() it.
Next, let’s look at how to get a Company (and its member sites) using a type projection and ObjectProjectionCriteria.
First, we need to define the XML criteria string. This is the tricky bit.
The Reference element at the front simply creates an MP reference to the CompanyMP management pack and sets the alias for that MP to ‘CompanyMP’. Then we just specify a very simple criteria that says ‘Get all the Company objects (and their member sites) where the CompanyID property = <some passed in value>’.
From there we create an ObjectProjectionCriteria object from the XML string and pass it to GetObjectProjectionReader():
ObjectProjectionCriteria opcCompanySites = new ObjectProjectionCriteria(strCompanySitesByCompanyID, mptpSites, emg);