Interface IWorkspaceDomains
- Namespace
- ESRI.ArcGIS.Geodatabase
- Assembly
- ESRI.Server.Geodatabase.dll
Provides access to members that return information about domains and allows you to add or delete domains.
[Guid("D80957F0-8883-11D2-AABB-00C04FA37B82")]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IWorkspaceDomains
Remarks
The IWorkspaceDomains interface is used for managing the collection of domains found within a workspace. Domains may be shared between fields in different object classes, thus they are managed (that is, created, deleted and modified) at the workspace level. It is important to keep in mind that a domain may not be deleted from a workspace if any field in an object class currently uses it. Domain names are also unique across a workspace; if you attempt to add a domain to a workspace and the specified name is already associated with an existing domain, an error will be returned.
Three of the four properties on the IWorkspaceDomain interface are used for returning to the user the domains that are currently associated with the workspace. The user can either request all of the domains (Domains), a particular domain by name (DomainByName), or all the domains that may be associated with a given field type (DomainsByFieldType).
Properties
CanDeleteDomain[string]
Indicates if the user can delete the domain.
bool CanDeleteDomain[string DomainName] { get; }
Parameters
DomainNamestring
Property Value
Remarks
CanDeleteDomain property returns TRUE if this domain can be deleted or FALSE if it cannot.
CanDeleteDomain, is used in conjunction with the DeleteDomain method. If the user attempts to delete a domain from a workspace rather than handling errors that may result during DeleteDomain (that is, the domain is in use), the user may first test whether the domain can be deleted via this property.
DomainByName[string]
The domain with the given name from the workspace.
IDomain DomainByName[string DomainName] { get; }
Parameters
DomainNamestring
Property Value
Remarks
This property returns an IDomain for the domain in the workspace with the name provided. The domain name is a String.
Domains
All the domains in the workspace.
IEnumDomain Domains { get; }
Property Value
Remarks
This property return an enumeration of all of the domains on a workspace as an IEnumDomain. You can loop through this enumeration to get each domain.
DomainsByFieldType[esriFieldType]
The domain with the given name from the workspace.
IEnumDomain DomainsByFieldType[esriFieldType Type] { get; }
Parameters
TypeesriFieldType
Property Value
Remarks
This property returns an enumeration of all of the domains in a workspace for a particular field type as an IEnumDomain. You can loop through this enumeration to get each domain.
Methods
AddDomain(IDomain)
Adds the given domain to the workspace.
int AddDomain(IDomain Domain)
Parameters
DomainIDomain
Returns
Remarks
The AddDomain method is used when adding a new domain to a workspace. An error will be returned if the domain name already exists on an existing domain within the workspace. AddDomain will return the identifier of the domain once it is added to the workspace.
An error will be raised if the domain name contains an invalid character when calling AddDomain. The list of invalid characters can be determined by using the ISQLSyntax::GetInvalidCharacters method, minus the slash (both / and \), hyphen (-), comma (,), and space characters.
If you are looking to assoicate an existing domain to a field (or subtype) see IClassSchemaEdit::AlterDomain (or ISubtypes::SetDomain).
public void AddDomain(IWorkspace workspace, string nameOfDomain)
{
//The function shows how to create a new range domain, then add it to the workspace.
IWorkspaceDomains workspaceDomains = workspace as IWorkspaceDomains;
//Create a new range domain
IRangeDomain rangeDomain = new RangeDomainClass();
rangeDomain.MaxValue = 2000;
rangeDomain.MinValue = 500;
IDomain domain = rangeDomain as IDomain;
domain.Name = nameOfDomain;
domain.FieldType = esriFieldType.esriFieldTypeDouble;
domain.SplitPolicy = esriSplitPolicyType.esriSPTGeometryRatio;
domain.MergePolicy = esriMergePolicyType.esriMPTSumValues;
//Add the new domain to the workspace;
workspaceDomains.AddDomain(domain);
}
DeleteDomain(string)
Deletes the given domain from the workspace.
void DeleteDomain(string DomainName)
Parameters
DomainNamestring
Remarks
This method will delete a domain from the workspace. For DeleteDomain to execute successfully, you must be connected to the workspace as the user who created the domain you are deleting, and the domain must not be in use by any object classes in the database. Use the CanDeleteDomain property to determine if a domain can be deleted. To unassociate a domain with a field, use the IClassSchemaEdit::AlterDomain method.