Represents a collection containing all the columns in the Table.

Namespace:  ESRI.ArcGISExplorer.Data

Assembly:  ESRI.ArcGISExplorer (in ESRI.ArcGISExplorer.dll) Version: 2.0.0.1500 (2.0.0.1500)

Syntax

C#
public sealed class ColumnCollection : IEnumerable<Column>, 
	IEnumerable
Visual Basic (Declaration)
Public NotInheritable Class ColumnCollection _
	Implements IEnumerable(Of Column), IEnumerable

Remarks

You can return a Column from the ColumnCollection by name or by index position; in C# use the indexer property on the collection (using this[] syntax) whereas in VB.NET you need to use the Item property.

Some of the columns in a Table are system-managed but their names vary between data source types. You can use the following properties to return the appropriate column name irrespective of data source:

  • ObjectIDColumnName returns the name of the unique identifier Column.
  • SpatialColumnName returns the name of Column which stores geometries in a spatially enabled Table.
  • LengthColumnName returns the name of the Column responsible for storing length information in spatially enabled Tables which have a Polygon or Polyline GeometryType.
  • AreaColumnName returns the name of the Column responsible for storing area information in spatially enabled Tables which have a Polygon GeometryType.
Some data sources, such a Table in an RDBMS (e.g Oracle), may not contain a unique identifier column and this situation can be checked for using the HasObjectIDColumn property.

You can find a Column by name (FindColumn) or by alias (FindColumnByAliasName) or you can return a ReadOnlyCollection of all column names (GetColumnNames) or column alias names (GetColumnAliasNames) in the Table.

Examples

The code below opens the Regions file geodatabase feature class and shows how to loop over all the columns in the Table using two different approaches.
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");

//return a collection containing all columns in the Regions table
ColumnCollection columns = regionsTable.Columns;

//Example 1 - use a for each loop to iterate over all columns in the Regions table
foreach (Column col in columns)
{
  //Print the name of each column
  System.Diagnostics.Debug.Print(col.Name);
  //Print the column type
  System.Diagnostics.Debug.Print(col.Type.ToString());
}

//Example 2 - alternative approach - use a for/next loop to access each column by index position
for (int i = 0; i < columns.Count; i++)
{
  Column col = columns[i];
  //Print the name of each column
  System.Diagnostics.Debug.Print(col.Name);
  //Print the column type
  System.Diagnostics.Debug.Print(col.Type.ToString());
}
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")

'return a collection containing all columns in the Regions table
Dim columns As ColumnCollection = regionsTable.Columns

'Example 1 - use a for each loop to iterate over all columns in the Regions table
For Each col As Column In columns
  'Print the name of each column
  System.Diagnostics.Debug.Print(col.Name)
  'Print the column type
  System.Diagnostics.Debug.Print(col.Type.ToString())
Next

'Example 2 - alternative approach - use a for loop to access each column by index position
For i As Integer = 0 To columns.Count - 1
  Dim col As Column = columns.Item(i)
  'Print the name of each column
  System.Diagnostics.Debug.Print(col.Name)
  'Print the column type
  System.Diagnostics.Debug.Print(col.Type.ToString())
Next

Inheritance Hierarchy

System..::.Object

  ESRI.ArcGISExplorer.Data..::.ColumnCollection

See Also