在管理要素类时,数据库中存储的要素类一般是英文名称,但为了显示更容易理解,我们通常会设置要素类别名和字段别名。代码中读取要素类别名很简单,如下:
featureClass.AliasName
IFeatureClass的AliasName是只读属性,不能修改;官方帮助是提示了,需要使用IClassSchemaEdit接口。
实现如下:
/// <summary> /// 修改要素类别名 /// </summary> /// <param name="featureClass">要素类</param> /// <param name="aliasName">别名</param> private static void ChangeFcAliasName(IFeatureClass featureClass, string aliasName) { ISchemaLock schemaLock = featureClass as ISchemaLock; try { schemaLock?.ChangeSchemaLock(esriSchemaLock.esriExclusiveSchemaLock); IClassSchemaEdit classSchemaEdit = featureClass as IClassSchemaEdit; classSchemaEdit?.AlterAliasName(aliasName); } finally { schemaLock?.ChangeSchemaLock(esriSchemaLock.esriSharedSchemaLock); } }