This document is archived and information here might be outdated.  Recommended version.

IWorkspaceDomains.AddDomain Method (ArcObjects .NET 10.8 SDK)
ArcObjects Help for .NET developers > ArcObjects Help for .NET developers > ArcObjects namespaces > Geodatabase > ESRI.ArcGIS.GeoDatabase > Interfaces > IW > IWorkspaceDomains Interface > IWorkspaceDomains.AddDomain Method
ArcGIS Developer Help

IWorkspaceDomains.AddDomain Method

Adds the given domain to the workspace.

[Visual Basic .NET]
Public Function AddDomain ( _
    ByVal Domain As IDomain _
) As Integer
public int AddDomain (
    IDomain Domain
HRESULT AddDomain(
  IDomain* Domain
Domain [in]

Domain is a parameter of type IDomain*

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.


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;

See Also

IWorkspaceDomains Interface