ArcGIS Explorer Component Help |
Column..::.HasDomain Property |
Column Class Example See Also |
Gets a value indicating whether the Column has a domain defined against it.
Namespace:
ESRI.ArcGISExplorer.DataAssembly: ESRI.ArcGISExplorer (in ESRI.ArcGISExplorer.dll) Version: 2.0.0.1500 (2.0.0.1500)
Syntax
C# |
---|
public bool HasDomain { get; } |
Visual Basic (Declaration) |
---|
Public ReadOnly Property HasDomain As Boolean |
Field Value
trueTruetruetrue (True in Visual Basic) if the Column has a domain defined against it; otherwise, falseFalsefalsefalse (False in Visual Basic).Examples
The code below uses the HasDomain property to check that a Column in a geodatabase feature class has
an associated domain then returns the Domain and prints 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