ArcGIS Pro 3.4 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 Datastore GetDatastore()
    Public Function GetDatastore() As Datastore

    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
    public async Task ObtainingGeodatabaseFromFeatureLayer()
    {
        IEnumerable<Layer> layers = MapView.Active.Map.Layers.Where(layer => layer is FeatureLayer);
    
        await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
        {
            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, Windows 10

    ArcGIS Pro version: 3 or higher.
    See Also