title: VMWare VIM SDK. List all VM's working, but list all datasources does not. Am I missing something?
body: <p>My goal is to get a listing of all the DataStores in a specific datacenter.  I'm able to list all of the Hosts, and VM's, but not the Datastores, and I don't understand why (I'm still learning the API's).  Any insight would be appreciated.</p>
  
  <p>Here's the code for grabbing all of the VM's (this works as expected):</p>
  
  <pre><code>public List&lt;VM&gt; getVMsInDatacenter(String datacenter, IEnumerable&lt;String&gt; properties)
  {
    List&lt;VM&gt; VMs = null;
  
    this.joinConnection((appUtil) =&gt;
    {
      var svcUtil = appUtil.getServiceUtil();
      var dcMoRef = svcUtil.GetDecendentMoRef(null, "Datacenter", datacenter);
  
      var typeinfo = buildTypeInfo("VirtualMachine", properties.ToList());
  
      VMs = buildVMsFromObjectContent(svcUtil.GetContentsRecursively(null, dcMoRef, typeinfo, true));
    });
    return VMs;
  }
  </code></pre>
  
  <p>Here is the analogous code for the Datastore (which does not work as expected):</p>
  
  <pre><code>public List&lt;DataStore&gt; getDataStoresInDatacenter(String datacenter, IEnumerable&lt;String&gt; properties)
  {
    List&lt;DataStore&gt; DataStores = null;
  
    this.joinConnection((appUtil) =&gt;
    {
      var svcUtil = appUtil.getServiceUtil();
      var dcMoRef = svcUtil.GetDecendentMoRef(null, "Datacenter", datacenter);
  
      var typeinfo = buildTypeInfo("Datastore", properties.ToList());
  
      DataStores = buildDataStoresFromObjectContent(svcUtil.GetContentsRecursively(null, dcMoRef, typeinfo, true));
    });
    return DataStores;
  }
  </code></pre>
  
  <p>appUtil is an instantiation of the AppUtil class that came with the VIM SDK samples.  It houses functionality for connecting, querying, etc.</p>
  
  <p>joinConnection is a method for connecting, or re-using a connection if we've already connected.</p>
  
  <p>If there are any other questions about the code, please let me know.</p>
  
  <p>Also, if there's a better way, I'd like to know that too :)</p>