Object classes in a Geodatabase can have between one and three names. The name of the object class, which is the same as the name of the table in the DBMS in which the objects in the object class are stored, the alias name which the user can set for display purposes in end user applications. The third name is the model name which is a tool for developers of custom objects to use to guarantee the names of objects independent of the true name or alias name.
代码:以gdb中图层为例修改图层名称(name)和别名(alias name)
public void AlterName()
{
Type type = Type.GetTypeFromProgID("esriDataSourcesGDB.FileGDBWorkspaceFactory");
IWorkspaceFactory pWorksapcFactory = (IWorkspaceFactory)Activator.CreateInstance(type);
IWorkspace pWorkspace = pWorksapcFactory.OpenFromFile(@"F:\GIS测试数据\测试.gdb", 0);
IFeatureWorkspace pFWK = pWorkspace as IFeatureWorkspace;
IFeatureClass pFeatureClass = pFWK.OpenFeatureClass("SSS");
//修改图层名称
IDataset dataset = pFeatureClass as IDataset;
dataset.Rename("MC");
//修改图层别名
AlterAliasName(pFeatureClass);
}
/// <summary>
/// 修改数据集别名
/// </summary>
/// <param name="objectClass">对象类</param>
public void AlterAliasName(IObjectClass objectClass)
{
//cast for the IClassSchemaEdit
IClassSchemaEdit pOcSchemaEdit = objectClass as IClassSchemaEdit;
//set and exclusive lock on the class 设置并独占锁
ISchemaLock schemaLock = (ISchemaLock)objectClass;
schemaLock.ChangeSchemaLock(esriSchemaLock.esriExclusiveSchemaLock);
//alter the class extension for the class
pOcSchemaEdit.AlterAliasName("修改别名");
//release the exclusive lock 释放锁
schemaLock.ChangeSchemaLock(esriSchemaLock.esriSharedSchemaLock);
}