Gets the Domain assigned to the Column.

Namespace:  ESRI.ArcGISExplorer.Data

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

Syntax

C#
public Domain GetDomain()
Visual Basic (Declaration)
Public Function GetDomain As Domain

Return Value

A Domain object associated with the Column. Returns nullNothingnullptra null reference (Nothing in Visual Basic) if the Column has not been assigned a domain.

Examples

The code below returns the Domain associated with a Column in a geodatabase feature class using the GetDomain method as well as printing out all the names and values stored within it.
CopyC#
Table tanks = Table.OpenFileGeodatabaseTable(@"C:\Data\Montgomery.gdb", "tanks");

//check that the "AncillaryRole" column of the "tanks" feature class has a Domain and
//that the Table is not subtyped (i.e there can only be a single Domain defined for this column). 
if ((tanks.Columns["AncillaryRole"].HasDomain) && (tanks.IsSubtyped == false))
{
  //return the Domain
  Domain domain = tanks.Columns["AncillaryRole"].GetDomain();

  //check the Domain type
  if (domain.Type == DomainType.CodedValue)
  {
    CodedValueDomain cvDom = domain as CodedValueDomain;

    //Print the Domain name
    System.Diagnostics.Debug.Print(cvDom.Name);   //Prints "AncillaryRoleDomain"

    //Print out all the contents of the domain
    for (int i = 0; i < cvDom.GetCodedValuePairs().Count -1; i++)
    {
      string domainInfo  = string.Format("Value: {0}, Name: {1}",cvDom.GetCodedValuePairs().Keys[i].ToString(),
                                                                 cvDom.GetCodedValuePairs().Values[i].ToString());
      System.Diagnostics.Debug.Print(domainInfo);

    }
  }
}
CopyVB.NET
Dim tanks As Table = Table.OpenFileGeodatabaseTable("C:\Data\Montgomery.gdb", "tanks")

'check that the "AncillaryRole" column of the "tanks" feature class has a Domain and
'that the Table is not subtyped (i.e there can only be a single Domain defined for this column). 
If ((tanks.Columns.Item("AncillaryRole").HasDomain) And (tanks.IsSubtyped = False)) Then
  'return the Domain
  Dim domain As Domain = tanks.Columns.Item("AncillaryRole").GetDomain()

  'check the Domain type
  If (domain.Type = DomainType.CodedValue) Then

    Dim cvDom As CodedValueDomain = DirectCast(domain, CodedValueDomain)

    'Print the Domain name
    System.Diagnostics.Debug.Print(cvDom.Name)   'Prints "AncillaryRoleDomain"


    'Print out all the contents of the domain
    For i As Integer = 0 To cvDom.GetCodedValuePairs().Count - 1
      Dim domainInfo As String = String.Format("Value: {0}, Name: {1}", cvDom.GetCodedValuePairs().Keys.Item(i).ToString(), _
                                                                        cvDom.GetCodedValuePairs().Values.Item(i).ToString())
      System.Diagnostics.Debug.Print(domainInfo)

    Next

  End If
End If

See Also