ArcGIS Pro二次开发--数据库篇
获得一个的要素的数据库:
Geodatabase gdb = featureLayer.GetFeatureClass().GetDatastore() as Geodatabase;
表
var id = row.GetTable().GetID();
打开数据库
Geodatabase fileGeodatabase = new Geodatabase(new FileGeodatabaseConnectionPath(new Uri(@"d:\gisoracle.gdb")));
sde数据库:
Geodatabase enterpriseGeodatabaseViaConnectionFile = new Geodatabase(new DatabaseConnectionFile(new Uri(@"path\to\the\sde\file"))); DatabaseConnectionProperties connectionProperties = new DatabaseConnectionProperties(EnterpriseDatabaseType.SQLServer) { AuthenticationMode = AuthenticationMode.DBMS, Instance = "machineName\\instanceName", Database = "databaseName", User = "username", Password = "Not1234" Version = "dbo.DEFAULT" }; Geodatabase enterpriseGeodatabaseViaConnectionProperties = new Geodatabase(connectionProperties);
打开要素类
FeatureClass table = geodatabase.OpenDataset<FeatureClass>("FeatureClassName");
打开表
Table table = geodatabase.OpenDataset<Table>("FeatureClassName");
打开数据集
FeatureDataset FeatureDataset = geodatabase.OpenDataset<FeatureDataset>("FeatureDatasetName");