GetDatastore Method (GDBProjectItem)
Gets the
ArcGIS.Core.Data.Datastore associated with the workspace corresponding to
ArcGIS.Desktop.Core.Item.Path. This method must be called on the MCT. Use QueuedTask.Run.
Return Value
A specific
ArcGIS.Core.Data.Datastore (e.g.,
ArcGIS.Core.Data.Geodatabase) associated with the workspace corresponding to
ArcGIS.Desktop.Core.Item.Path. If the workspace is not currently supported, an instance of
ArcGIS.Core.Data.UnknownDatastore is returned.
Obtaining Geodatabase from Project Item
{
await QueuedTask.Run(() =>
{
IEnumerable<GDBProjectItem> gdbProjectItems = Project.Current.GetItems<GDBProjectItem>();
foreach (GDBProjectItem gdbProjectItem in gdbProjectItems)
{
using (Datastore datastore = gdbProjectItem.GetDatastore())
{
//Unsupported datastores (non File GDB and non Enterprise GDB) will be of type UnknownDatastore
if (datastore is UnknownDatastore)
continue;
Geodatabase geodatabase = datastore as Geodatabase;
// Use the geodatabase.
}
}
});
}
Target Platforms: Windows 11 Home, Pro, Enterprise (64 bit)
ArcGIS Pro version: 3.0 or higher.