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
public async Task ObtainingGeodatabaseFromProjectItem()
{
IEnumerable<GDBProjectItem> gdbProjectItems = Project.Current.GetItems<GDBProjectItem>();
await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
{
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, Windows 10
ArcGIS Pro version: 3.0 or higher.