User-defined attributes can be created using common data types, such as numbers or strings. They can also be limited to a specified enumeration of values. A list of possible values such an attribute can have is called a “domain.” Each domain corresponds to a single table in the database. Domains are created using the Structure.AddDomainTable() method.
The following line creates a “DEMO_MAINTENANCE_TYPE_TBD” domain:
AddDomainTable(
"DEMO_MAINTENANCE_TYPE_TBD",
"DEMO MAINTENANCE TYPE");
Values within a domain are added individually. The following code adds three new values to the DEMO_MAINTAINENANCE_TYPE_TBD domain: “u”, “o”, and “tbd”:
AddDomainEntry("DEMO_MAINTENANCE_TYPE_TBD",
1,
"unknown",
"u",
"description",
true);
AddDomainEntry("DEMO_MAINTENANCE_TYPE_TBD",
10000,
"other",
"o",
"description"
true);
AddDomainEntry("DEMO_MAINTENANCE_TYPE_TBD",
10001,
"to be determined",
"tbd",
"description"
true);
A domain relationship is used to set a particular attribute to use the defined domain. The following line sets the ID_MAINTENANCE_TYPE attribute of the DEMO_MAINTENANCE feature class to use the DEMO_MAINTENANCE_TYPE_TBD domain:
AddRelationToDomain(
"DEMO_MAINTENANCE_TYPE_TBD",
"DEMO_MAINTENANCE",
"ID_MAINTENANCE_TYPE");
Now an ID_MAINTENANCE_TYPE attribute can hold one of three values: “u”, “o”, or “tbd”.