IWorkspaceDomains Interface

Provides access to members that return information about domains and allows you to add or delete domains.

Members

Name Description
Method AddDomain Adds the given domain to the workspace.
Read-only property CanDeleteDomain Indicates if the user can delete the domain.
Method DeleteDomain Deletes the given domain from the workspace.
Read-only property DomainByName The domain with the given name from the workspace.
Read-only property Domains All the domains in the workspace.
Read-only property DomainsByFieldType The domain with the given name from the workspace.

IWorkspaceDomains.AddDomain Method

Adds the given domain to the workspace.

Public Function AddDomain ( _
    ByVal Domain As IDomain _
) As Integer
public int AddDomain (
    IDomain Domain
);

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);

    }

IWorkspaceDomains.CanDeleteDomain Property

Indicates if the user can delete the domain.

Public Function get_CanDeleteDomain ( _
    ByVal DomainName As String _
) As Boolean
public bool get_CanDeleteDomain (
    string DomainName
);

Remarks

CanDeleteDomainproperty 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.

IWorkspaceDomains.DeleteDomain Method

Deletes the given domain from the workspace.

Public Sub DeleteDomain ( _
    ByVal DomainName As String _
)
public void DeleteDomain (
    string DomainName
);

Errors Returned

FDO_E_DOMAIN_USED_AS_DEFAULT_DOMAIN: The domain is associated with a field as the default domain. Remove the association with the IClassSchemaEdit::AlterDomain method.

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.

IWorkspaceDomains.DomainByName Property

The domain with the given name from the workspace.

Public Function get_DomainByName ( _
    ByVal DomainName As String _
) As IDomain
public IDomain get_DomainByName (
    string DomainName
);

Description

DomainByNameproperty returns an IDomain interface to the domain specified by the domain name parameter passed in.

Remarks

This property returns an IDomain for the domain in the workspace with the name provided. The domain name is a String.

IWorkspaceDomains.Domains Property

All the domains in the workspace.

Public ReadOnly Property Domains As IEnumDomain
public IEnumDomain Domains {get;}

Description

The Domains property returns an IEnumDomains enumerator for all of the domains from the underlying workspace.

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.

IWorkspaceDomains.DomainsByFieldType Property

The domain with the given name from the workspace.

Public Function get_DomainsByFieldType ( _
    ByVal Type As esriFieldType _
) As IEnumDomain
public IEnumDomain get_DomainsByFieldType (
    esriFieldType Type
);

Description

DomainsByFieldTypeproperty returns a IEnumDomain interface to all the domains that apply to the esriFieldType parameter passed in for the specified workspace coclass.

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.

Classes that implement IWorkspaceDomains

Classes Description
Workspace Workspace Object.

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).

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.