public void Rename(string Name) { log.enterFunc("Rename"); FeatureDataset.Rename(Name); }
public IDataset Copy(string copyName, IWorkspace copyWorkspace) { log.enterFunc("Copy"); return(FeatureDataset.Copy(copyName, copyWorkspace)); }
public void Delete() { log.enterFunc("Delete"); FeatureDataset.Delete(); }
public bool CanRename() { log.enterFunc("CanRename"); return(FeatureDataset.CanRename()); }
public bool CanDelete() { log.enterFunc("CanDelete"); return(FeatureDataset.CanDelete()); }
public bool CanCopy() { log.enterFunc("CanCopy"); return(FeatureDataset.CanCopy()); }
public void MainMethodCode() { // To run this code import the LocalGovernment.gdb to a sql server instance with the following settings. DatabaseConnectionProperties connectionProperties = new DatabaseConnectionProperties(EnterpriseDatabaseType.SQLServer) { AuthenticationMode = AuthenticationMode.DBMS, // Where testMachine is the machine where the instance is running and testInstance is the name of the SqlServer instance. Instance = @"testMachine\testInstance", // Provided that a database called LocalGovernment has been created on the testInstance and geodatabase has been enabled on the database. Database = "LocalGovernment", // Provided that a login called gdb has been created and corresponding schema has been created with the required permissions. User = "******", Password = "******", Version = "dbo.DEFAULT" }; using (Geodatabase geodatabase = new Geodatabase(connectionProperties)) { // Safe cast to Table to get a table reference. using (Table table = geodatabase.OpenDataset <Table>("LocalGovernment.GDB.EmployeeInfo")) { } // Open a featureClass (within a feature dataset or outside a feature dataset). using (FeatureClass featureClass = geodatabase.OpenDataset <FeatureClass>("LocalGovernment.GDB.AddressPoint")) { } // You can open a FeatureClass as a Table which will give you a Table Reference. using (Table featureClassAsTable = geodatabase.OpenDataset <Table>("LocalGovernment.GDB.AddressPoint")) { // But it is really a FeatureClass object. FeatureClass featureClassOpenedAsTable = featureClassAsTable as FeatureClass; } // Open a FeatureDataset. using (FeatureDataset featureDataset = geodatabase.OpenDataset <FeatureDataset>("LocalGovernment.GDB.Address")) { } // Open a RelationsipClass. Just as you can open a FeatureClass as a Table, you can also open an AttributedRelationshipClass as a RelationshipClass. using (RelationshipClass relationshipClass = geodatabase.OpenDataset <RelationshipClass>("LocalGovernment.GDB.AddressPointHasSiteAddresses")) { } try { geodatabase.OpenDataset <Table>(null); } catch (ArgumentException exception) { //Providing a null for dataset name gives argument exception } try { geodatabase.OpenDataset <Table>("LocalGovernment.GDB.Something"); } catch (InvalidOperationException exception) { // Providing a non-existent dataset name gives Invalid Operation Exception } } }
public void MainMethodCode() { using (Geodatabase fileGeodatabase = new Geodatabase(new FileGeodatabaseConnectionPath(new Uri(@"C:\Data\LocalGovernment.gdb")))) using (FeatureDataset featureDataset = fileGeodatabase.OpenDataset<FeatureDataset>("Address")) using (FeatureClass featureClass = featureDataset.OpenDataset<FeatureClass>("AddressPoint")) using (RelationshipClass relationshipClass = featureDataset.OpenDataset<RelationshipClass>("AddressPointHasSiteAddresses")) { IReadOnlyList<Definition> definitions = fileGeodatabase.GetRelatedDefinitions(featureDataset.GetDefinition(), DefinitionRelationshipType.DatasetInFeatureDataset); foreach (Definition definition in definitions) { Dataset dataset = null; try { if (definition.DatasetType == DatasetType.Table) { dataset = featureDataset.OpenDataset<Table>(definition.GetName()); } else if (definition.DatasetType == DatasetType.FeatureClass) { dataset = featureDataset.OpenDataset<FeatureClass>(definition.GetName()); } else if (definition.DatasetType == DatasetType.RelationshipClass) { dataset = featureDataset.OpenDataset<RelationshipClass>(definition.GetName()); } else if (definition.DatasetType == DatasetType.AttributedRelationshipClass) { dataset = featureDataset.OpenDataset<AttributedRelationshipClass>(definition.GetName()); } // Do something with dataset } catch (InvalidOperationException exception) { //This exception is thrown if one of the datasets in the FeatureDatasets are not supported and thus marked as Unknown Console.WriteLine(exception); } finally { // Should explicitly dispose of a Dataset. if (dataset != null) dataset.Dispose(); } } } // Opening a Non-Versioned SQL Server instance. DatabaseConnectionProperties connectionProperties = new DatabaseConnectionProperties(EnterpriseDatabaseType.SQLServer) { AuthenticationMode = AuthenticationMode.DBMS, // Where testMachine is the machine where the instance is running and testInstance is the name of the SqlServer instance. Instance = @"testMachine\testInstance", // Provided that a database called LocalGovernment has been created on the testInstance and geodatabase has been enabled on the database. Database = "LocalGovernment", // Provided that a login called gdb has been created and corresponding schema has been created with the required permissions. User = "******", Password = "******", Version = "dbo.DEFAULT" }; using (Geodatabase geodatabase = new Geodatabase(connectionProperties)) using (FeatureDataset enterpriseFeatureDataset = geodatabase.OpenDataset<FeatureDataset>("LocalGovernment.GDB.ReferenceData")) using (FeatureClass communityCenter = enterpriseFeatureDataset.OpenDataset<FeatureClass>("LocalGovernment.GDB.CommunityCenter")) using (FeatureClass library = enterpriseFeatureDataset.OpenDataset<FeatureClass>("LocalGovernment.GDB.Library")) { try { // Trying to open non-existent RelationshipClasses and AttributedRelationshipClasses. Dataset badRelationshipClass = enterpriseFeatureDataset.OpenDataset<RelationshipClass>("SomeGibberish"); Dataset badAttributedRelationshipClass = enterpriseFeatureDataset.OpenDataset<AttributedRelationshipClass>("SomeGibberish"); } catch (GeodatabaseCatalogDatasetException exception) { // Thrown for RelationshipClass and AttributedRelationshipClass. } try { // Trying to open non-existent FeatureClasses. Dataset badFeatureClass = enterpriseFeatureDataset.OpenDataset<FeatureClass>("SomeGibberish"); } catch (GeodatabaseDatasetException exception) { // Thrown for FeatureClasses. } try { // Tables and FeatureDatasets cannot exist in a FeatureDataset. Dataset badFeatureDataset = enterpriseFeatureDataset.OpenDataset<FeatureDataset>("SomeGibberish"); Dataset badTable = enterpriseFeatureDataset.OpenDataset<Table>("SomeGibberish"); } catch (InvalidOperationException exception) { // Thrown for Table and FeatureDataset. } } }