public sealed class FieldDescription : Description
Public NotInheritable Class FieldDescription Inherits Description
public sealed class FieldDescription : Description
Public NotInheritable Class FieldDescription Inherits Description
// Create a PoleInspection table with the following fields // GlobalID // ObjectID // InspectionDate (date) // InspectionResults (pre-existing InspectionResults coded value domain) // InspectionNotes (string) // This static helper routine creates a FieldDescription for a GlobalID field with default values FieldDescription globalIDFieldDescription = FieldDescription.CreateGlobalIDField(); // This static helper routine creates a FieldDescription for an ObjectID field with default values FieldDescription objectIDFieldDescription = FieldDescription.CreateObjectIDField(); // Create a FieldDescription for the InspectionDate field FieldDescription inspectionDateFieldDescription = new FieldDescription("InspectionDate", FieldType.Date) { AliasName = "Inspection Date" }; // This static helper routine creates a FieldDescription for a Domain field (from a pre-existing domain) FieldDescription inspectionResultsFieldDescription = FieldDescription.CreateDomainField("InspectionResults", new CodedValueDomainDescription(inspectionResultsDomain)); inspectionResultsFieldDescription.AliasName = "Inspection Results"; // This static helper routine creates a FieldDescription for a string field FieldDescription inspectionNotesFieldDescription = FieldDescription.CreateStringField("InspectionNotes", 512); inspectionNotesFieldDescription.AliasName = "Inspection Notes"; // Assemble a list of all of our field descriptions List<FieldDescription> fieldDescriptions = new List<FieldDescription>() { globalIDFieldDescription, objectIDFieldDescription, inspectionDateFieldDescription, inspectionResultsFieldDescription, inspectionNotesFieldDescription }; // Create a TableDescription object to describe the table to create TableDescription tableDescription = new TableDescription("PoleInspection", fieldDescriptions); // Create a SchemaBuilder object SchemaBuilder schemaBuilder = new SchemaBuilder(geodatabase); // Add the creation of PoleInspection to our list of DDL tasks schemaBuilder.Create(tableDescription); // Execute the DDL bool success = schemaBuilder.Build(); // Inspect error messages if (!success) { IReadOnlyList<string> errorMessages = schemaBuilder.ErrorMessages; //etc. }
// Creating a FeatureDataset named as 'Parcel_Information' and a FeatureClass with name 'Parcels' in one operation string featureDatasetName = "Parcel_Information"; string featureClassName = "Parcels"; SchemaBuilder schemaBuilder = new SchemaBuilder(geodatabase); // Create a FeatureDataset token FeatureDatasetDescription featureDatasetDescription = new FeatureDatasetDescription(featureDatasetName, SpatialReferences.WGS84); FeatureDatasetToken featureDatasetToken = schemaBuilder.Create(featureDatasetDescription); // Create a FeatureClass description FeatureClassDescription featureClassDescription = new FeatureClassDescription(featureClassName, new List<FieldDescription>() { new FieldDescription("Id", FieldType.Integer), new FieldDescription("Address", FieldType.String) }, new ShapeDescription(GeometryType.Point, SpatialReferences.WGS84)); // Create a FeatureClass inside a FeatureDataset FeatureClassToken featureClassToken = schemaBuilder.Create(new FeatureDatasetDescription(featureDatasetToken), featureClassDescription); // Build status bool buildStatus = schemaBuilder.Build(); // Build errors if (!buildStatus) { IReadOnlyList<string> errors = schemaBuilder.ErrorMessages; }
// Creating a FeatureClass named as 'Tax_Jurisdiction' in existing FeatureDataset with name 'Parcels_Information' string featureDatasetName = "Parcels_Information"; string featureClassName = "Tax_Jurisdiction"; // Create a FeatureClass description FeatureClassDescription featureClassDescription = new FeatureClassDescription(featureClassName, new List<FieldDescription>() { new FieldDescription("Tax_Id", FieldType.Integer), new FieldDescription("Address", FieldType.String) }, new ShapeDescription(GeometryType.Point, SpatialReferences.WGS84)); FeatureDatasetDefinition featureDatasetDefinition = geodatabase.GetDefinition<FeatureDatasetDefinition>(featureDatasetName); SchemaBuilder schemaBuilder = new SchemaBuilder(geodatabase); // Create a FeatureClass inside a FeatureDataset using a FeatureDatasetDefinition schemaBuilder.Create(new FeatureDatasetDescription(featureDatasetDefinition), featureClassDescription); // Build status bool buildStatus = schemaBuilder.Build(); // Build errors if (!buildStatus) { IReadOnlyList<string> errors = schemaBuilder.ErrorMessages; }
// Removing all fields from 'Parcels' table except following // Tax_Code // Parcel_Address // The table to remove fields string tableName = "Parcels"; TableDefinition tableDefinition = geodatabase.GetDefinition<TableDefinition>(tableName); IReadOnlyList<Field> fields = tableDefinition.GetFields(); // Existing fields from 'Parcels' table Field taxCodeField = fields.First(f => f.Name.Equals("Tax_Code")); Field parcelAddressField = fields.First(f => f.Name.Equals("Parcel_Address")); FieldDescription taxFieldDescription = new FieldDescription(taxCodeField); FieldDescription parcelAddressFieldDescription = new FieldDescription(parcelAddressField); // Fields to retain in modified table List<FieldDescription> fieldsToBeRetained = new List<FieldDescription>() { taxFieldDescription, parcelAddressFieldDescription }; // New description of the 'Parcels' table with the 'Tax_Code' and 'Parcel_Address' fields TableDescription modifiedTableDescription = new TableDescription(tableName, fieldsToBeRetained); SchemaBuilder schemaBuilder = new SchemaBuilder(geodatabase); // Remove all fields except the 'Tax_Code' and 'Parcel_Address' fields schemaBuilder.Modify(modifiedTableDescription); schemaBuilder.Build();
System.Object
ArcGIS.Core.Data.DDL.Description
ArcGIS.Core.Data.DDL.FieldDescription
Target Platforms: Windows 11, Windows 10, Windows 8.1