ArcGIS Pro 3.4 API Reference Guide
ArcGIS.Core.Data Namespace / Table Class / GetControllerDatasets Method
Example Version

GetControllerDatasets Method
Gets a IReadOnlyList of controller datasets of a specific Dataset type that this table or feature class participates in. This method must be called on the MCT. Use QueuedTask.Run.
Syntax
public IReadOnlyList<Dataset> GetControllerDatasets()

Return Value

A IReadOnlyList of controller datasets of a specific Dataset type that this table or feature class participates in.
Exceptions
ExceptionDescription
This table does not support controller datasets.
A geodatabase-related exception has occurred.
Remarks
If IsControllerDatasetSupported returns false, calling this method will result in an exception.
Example
Get parcel fabric from table
public static ParcelFabric GetParcelFabricFromTable(Table table)
{
  ParcelFabric myParcelFabricDataset = null;
  if (table.IsControllerDatasetSupported())
  {
    // Tables can belong to multiple controller datasets, but at most one of them will be a parcel fabric

    IReadOnlyList<Dataset> controllerDatasets = table.GetControllerDatasets();
    foreach (Dataset controllerDataset in controllerDatasets)
    {
      if (controllerDataset is ParcelFabric)
      {
        myParcelFabricDataset = controllerDataset as ParcelFabric;
      }
      else
      {
        controllerDataset.Dispose();
      }
    }
  }
  return myParcelFabricDataset;
}
Get a Utility Network from a Table
public static UtilityNetwork GetUtilityNetworkFromTable(Table table)
{
  UtilityNetwork utilityNetwork = null;

  if (table.IsControllerDatasetSupported())
  {
    // Tables can belong to multiple controller datasets, but at most one of them will be a UtilityNetwork
    IReadOnlyList<Dataset> controllerDatasets = table.GetControllerDatasets();

    foreach (Dataset controllerDataset in controllerDatasets)
    {
      if (controllerDataset is UtilityNetwork)
      {
        utilityNetwork = controllerDataset as UtilityNetwork;
      }
      else
      {
        controllerDataset.Dispose();
      }
    }
  }
  return utilityNetwork;
}
Get a Utility Network from a Layer
// This routine obtains a utility network from a FeatureLayer, SubtypeGroupLayer, or UtilityNetworkLayer
public static UtilityNetwork GetUtilityNetworkFromLayer(Layer layer)
{
  UtilityNetwork utilityNetwork = null;

  if (layer is UtilityNetworkLayer)
  {
    UtilityNetworkLayer utilityNetworkLayer = layer as UtilityNetworkLayer;
    utilityNetwork = utilityNetworkLayer.GetUtilityNetwork();
  }

  else if (layer is SubtypeGroupLayer)
  {
    CompositeLayer compositeLayer = layer as CompositeLayer;
    utilityNetwork = GetUtilityNetworkFromLayer(compositeLayer.Layers.First());
  }

  else if (layer is FeatureLayer)
  {
    FeatureLayer featureLayer = layer as FeatureLayer;
    using (FeatureClass featureClass = featureLayer.GetFeatureClass())
    {
      if (featureClass.IsControllerDatasetSupported())
      {
        IReadOnlyList<Dataset> controllerDatasets = new List<Dataset>();
        controllerDatasets = featureClass.GetControllerDatasets();
        foreach (Dataset controllerDataset in controllerDatasets)
        {
          if (controllerDataset is UtilityNetwork)
          {
            utilityNetwork = controllerDataset as UtilityNetwork;
          }
          else
          {
            controllerDataset.Dispose();
          }
        }
      }
    }
  }
  return utilityNetwork;
}
Requirements

Target Platforms: Windows 11, Windows 10

ArcGIS Pro version: 3 or higher.
See Also