CodeSmith实用技巧(四):使用扩展属性
2007-06-15 11:06
399 查看
SchemaExplorer允许我们获取数据库中一些对象的信息。如果你使用的是SQL Server2000数据库,你可以通过扩展属性获取很多对象的有用的信息。例如:SQL Server定义了一个扩展属性来标识表中的唯一标识字段,在模版中可以这样写:
%>
CodeSmith定义的扩展属性包括table columns, view columns, 和 command parameters。
Table columns[/b]
CS_IsRowGuidCol
CS_IsIdentity
CS_IsComputed
CS_IsDeterministic
CS_IdentitySeed
CS_IdentityIncrement
CS_Default
view columns[/b]
CS_IsComputed
CS_IsDeterministic
command parameters[/b]
CS_Default
另外,每个对象都有一个CS_Description的扩展属性。你也可以通过SQL Server中的系统存储过程sp_addextendedproperty来创建自定义的扩展属性。例如:我们执行如下命令为Customer这张表的ID字段添加一个Caption的扩展属性:
sp_addextendedproperty 'caption', 'Customer ID', 'user', dbo, 'table', Customers, 'column', id
在数据库中执行完这条语句后,CodeSmith中将会在这个字段的扩展属性集合中加上Caption属性。有关SQL Server 中的扩展属性的内容请参考联机丛书。
%>
CodeSmith定义的扩展属性包括table columns, view columns, 和 command parameters。
Table columns[/b]
CS_IsRowGuidCol
CS_IsIdentity
CS_IsComputed
CS_IsDeterministic
CS_IdentitySeed
CS_IdentityIncrement
CS_Default
view columns[/b]
CS_IsComputed
CS_IsDeterministic
command parameters[/b]
CS_Default
另外,每个对象都有一个CS_Description的扩展属性。你也可以通过SQL Server中的系统存储过程sp_addextendedproperty来创建自定义的扩展属性。例如:我们执行如下命令为Customer这张表的ID字段添加一个Caption的扩展属性:
sp_addextendedproperty 'caption', 'Customer ID', 'user', dbo, 'table', Customers, 'column', id
在数据库中执行完这条语句后,CodeSmith中将会在这个字段的扩展属性集合中加上Caption属性。有关SQL Server 中的扩展属性的内容请参考联机丛书。
相关文章推荐
- CodeSmith实用技巧(四):使用扩展属性
- CodeSmith实用技巧(六):使用XML 属性
- CodeSmith实用技巧(六):使用XML 属性
- CodeSmith实用技巧(六):使用XML 属性
- CodeSmith实用技巧(一):使用StringCollection
- 分享两个实用的ASP.NET开发技巧——使用WebMethod实现ajax和控件的ClientIDMode属性
- 实用的CSS3属性和使用技巧
- CodeSmith实用技巧(一):使用StringCollection
- 少见但绝对实用的CodeSmith使用技巧
- CodeSmith实用技巧(三):使用FileDialogAttribute
- 实用技巧:利用SQL Server的扩展属性自动生成数据字典
- CodeSmith实用技巧(七):从父模版拷贝属性
- CodeSmith实用技巧(十三):使用CodeTemplateInfo对象
- CodeSmith实用技巧(二):使用FileNameEditor
- CodeSmith实用技巧(二):使用FileNameEditor
- CodeSmith实用技巧(十四):使用Progress对象
- CodeSmith实用技巧(三):使用FileDialogAttribute
- CodeSmith实用技巧(十五):使用快捷键
- CodeSmith实用技巧(十五):使用快捷键
- CodeSmith实用技巧(七):从父模版拷贝属性