How can I retrieve the count of InstanceObject for each InstanceDefinition with C#?

…and Databases.