Gets the type of the Column, which determines the type of data that can be stored in it.
Namespace:
ESRI.ArcGISExplorer.DataAssembly: ESRI.ArcGISExplorer (in ESRI.ArcGISExplorer.dll) Version: 2.0.0.1500 (2.0.0.1500)
Syntax
C# |
---|
public ColumnType Type { get; } |
Visual Basic (Declaration) |
---|
Public ReadOnly Property Type As ColumnType |
Field Value
One of the ColumnType values, which determines the type of data that can be stored in the Column.Examples
The code below provides a number of examples for working with ColumnCollection and Column properties.
The Type property is used in the first example to print the type of the Region column.
CopyC#
//Open the Regions feature class stored in the Scotland file geodatabase Geodatabase gdb = new Geodatabase(@"C:\Data\Scotland.gdb"); Table regionsTable = gdb.OpenTable("regions"); //Example 1 - column properties for the non-spatial, "Region" Column Column regionColumn = regionsTable.Columns["Region"]; System.Diagnostics.Debug.Print(regionColumn.Name); //Prints "Region" System.Diagnostics.Debug.Print(regionColumn.AliasName); //Prints "Region" System.Diagnostics.Debug.Print(regionColumn.Type.ToString()); //Prints "String" System.Diagnostics.Debug.Print(regionColumn.Length.ToString()); //Prints "50" //Check that the parent data container is a geodatabase as the IsNullable and Required column //properties only apply to this data format if (regionsTable.Parent is Geodatabase) { System.Diagnostics.Debug.Print(regionColumn.IsNullable.ToString()); //Prints "True" System.Diagnostics.Debug.Print(regionColumn.Required.ToString()); //Prints "False" } //Example 2 - column properties for the non-spatial, "ObjectID" column //Check that the Regions table has a unique identifier column if (regionsTable.Columns.HasObjectIDColumn) { //Get the unique identifier column Column oidColumn = regionsTable.Columns[regionsTable.Columns.ObjectIDColumnName]; System.Diagnostics.Debug.Print(oidColumn.Name); //Prints "OBJECTID" System.Diagnostics.Debug.Print(oidColumn.Required.ToString()); //Prints "True" System.Diagnostics.Debug.Print(oidColumn.IsNullable.ToString()); //Prints "False" } //Example 3 - column properties for the spatial, "Shape" column //Check that the Regions table can contain vector data if (regionsTable.IsSpatial) { //Get the column that can store geometry Column shapeColumn = regionsTable.Columns[regionsTable.Columns.SpatialColumnName]; System.Diagnostics.Debug.Print(shapeColumn.Name); //Prints "Shape" System.Diagnostics.Debug.Print(shapeColumn.CoordinateSystem.Name); //Prints "British_National_Grid" System.Diagnostics.Debug.Print(shapeColumn.HasZ.ToString()); //Prints "False" //check that this table can store Polygon geometries if (shapeColumn.GeometryType == GeometryType.Polygon) { //Get the column which stores the perimeter length of each geometry Column lengthCol = regionsTable.Columns[regionsTable.Columns.LengthColumnName]; System.Diagnostics.Debug.Print(lengthCol.Name); //Prints "Shape_Length" //Gets the column which stores the area of each geometry Column areaCol = regionsTable.Columns[regionsTable.Columns.AreaColumnName]; System.Diagnostics.Debug.Print(areaCol.Name); //Prints "Shape_Area" } }
CopyVB.NET
'Open regions feature class stored in the Scotland file geodatabase Dim gdb As Geodatabase = New Geodatabase("C:\Data\Scotland.gdb") Dim regionsTable As Table = gdb.OpenTable("regions") 'Example 1 - column properties for the non-spatial "Region" Column Dim regionColumn As Column = regionsTable.Columns.Item("Region") System.Diagnostics.Debug.Print(regionColumn.Name) 'Prints "Region" System.Diagnostics.Debug.Print(regionColumn.AliasName) 'Prints "Region" System.Diagnostics.Debug.Print(regionColumn.Type.ToString()) 'Prints "String" System.Diagnostics.Debug.Print(regionColumn.Length.ToString()) 'Prints "50" 'Check that the parent data container is a geodatabase as the IsNullable and Required column 'properties only apply to this data format If TypeOf regionsTable.Parent Is Geodatabase Then System.Diagnostics.Debug.Print(regionColumn.IsNullable.ToString()) 'Prints "True" System.Diagnostics.Debug.Print(regionColumn.Required.ToString()) 'Prints "False" End If 'Example 2 - column properties for the non-spatial, "ObjectID" column 'check that the Regions table has a unique identifier column If (regionsTable.Columns.HasObjectIDColumn) Then 'Get the unique identifier column Dim oidColumn As Column = regionsTable.Columns.Item(regionsTable.Columns.ObjectIDColumnName) System.Diagnostics.Debug.Print(oidColumn.Name) 'Prints "OBJECTID" System.Diagnostics.Debug.Print(oidColumn.Required.ToString()) 'Prints "True" System.Diagnostics.Debug.Print(oidColumn.IsNullable.ToString()) 'Prints "False" End If 'Example 3 - column properties for the spatial, "Shape" column 'check that the Regions table can contain vector data If regionsTable.IsSpatial Then 'Get the column that can store geometry Dim shapeColumn As Column = regionsTable.Columns.Item(regionsTable.Columns.SpatialColumnName) System.Diagnostics.Debug.Print(shapeColumn.Name) 'Prints "Shape" System.Diagnostics.Debug.Print(shapeColumn.CoordinateSystem.Name) 'Prints "British_National_Grid" System.Diagnostics.Debug.Print(shapeColumn.HasZ.ToString()) 'Prints "False" 'check that this table can store Polygon geometries If shapeColumn.GeometryType = GeometryType.Polygon Then 'Get the column which stores the perimeter length of each geometry Dim lengthCol As Column = regionsTable.Columns.Item(regionsTable.Columns.LengthColumnName) System.Diagnostics.Debug.Print(lengthCol.Name) 'Prints "Shape_Length" 'Gets the column which stores the area of each geometry Dim areaCol As Column = regionsTable.Columns.Item(regionsTable.Columns.AreaColumnName) System.Diagnostics.Debug.Print(areaCol.Name) 'Prints "Shape_Area" End If End If