Gets the first Row in the RowCollection.

Namespace:  ESRI.ArcGISExplorer.Data

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

Syntax

C#
public Row GetFirst()
Visual Basic (Declaration)
Public Function GetFirst As Row

Return Value

A Row object which represents a single record in the Table.

Remarks

This method is useful when the Search method is used to find a single row, as it negates the need to explicitly iterate over the RowCollection.

Be aware that if the same search is executed multiple times, it does not guarantee to return rows in the same order each time.

Examples

The code below illustrates how to use the GetFirst method to retrieve the first Row in a RowCollection.
CopyC#
{
  //Open file geodatabase feature class
  Table phoneMastsTable = Table.OpenFileGeodatabaseTable(@"C:\Data\Forestry.gdb", "Phonemasts");

  //Return a RowCollection from the query then access the first Row using the GetFirst method
  RowCollection phoneMasts = phoneMastsTable.Search(new Filter("MAST_REF='1932-O2'"));

  if (phoneMasts != null)
  {
    Row phoneMast = phoneMasts.GetFirst();
  }

  //Alternatively return the Row directly if confident that record will be found.
  //An exception will be thrown if the RowCollection is null
  Row phoneMast2 = phoneMastsTable.Search(new Filter("MAST_REF='1938-O2'")).GetFirst();

}
CopyVB.NET
'Open file geodatabase feature class
Dim phoneMastsTable As Table = Table.OpenFileGeodatabaseTable("C:\Data\Forestry.gdb", "Phonemasts")

'Return a RowCollection from the query then access the first Row using the GetFirst method
Dim phoneMasts As RowCollection = phoneMastsTable.Search(New Filter("MAST_REF='1932-O2'"))

If Not phoneMasts Is Nothing Then
  Dim phoneMast As Row = phoneMasts.GetFirst()
End If

'Alternatively return the Row directly if confident that record will be found.
'An exception will be thrown if the RowCollection is null
Dim phoneMast2 As Row = phoneMastsTable.Search(New Filter("MAST_REF='1938-O2'")).GetFirst()

See Also