ArcGIS Pro 3.7 API Reference Guide
ArcGIS.Core.Data Namespace / Dataset Class / GetDatastore Method
Example

In This Topic
    GetDatastore Method (Dataset)
    In This Topic
    Gets the data store of this dataset. This method must be called on the MCT. Use QueuedTask.Run.
    Syntax
    Public Function GetDatastore() As Datastore
    public Datastore GetDatastore()

    Return Value

    The data store of this dataset.
    Exceptions
    ExceptionDescription
    This dataset does not have an associated data store because it is either invalid, virtual or currently not supported.
    A geodatabase-related exception has occurred.
    Example
    Obtaining Geodatabase from FeatureLayer
    {
      await QueuedTask.Run(() =>
      {
        IEnumerable<Layer> layers =
          MapView.Active.Map.Layers.Where(layer => layer is FeatureLayer);
    
        foreach (FeatureLayer featureLayer in layers)
        {
          using (Table table = featureLayer.GetTable())
          using (Datastore datastore = table.GetDatastore())
          {
            if (datastore is UnknownDatastore)
              continue;
    
            Geodatabase geodatabase = datastore as Geodatabase;
          }
        }
      });
    }
    Requirements

    Target Platforms: Windows 11 Home, Pro, Enterprise (64 bit)

    ArcGIS Pro version: 3.0 or higher.
    See Also