Identity Field
=
<%
foreach
(ColumnSchema cs
in
SourceTable.Columns)
{
if( ((bool)cs.ExtendedProperties["CS_IsIdentity"].Value) == true)
{
Response.Write(cs.Name);
}
}
%>
CodeSmith
定义的扩展属性包括
table columns, view columns,
和
command parameters
。
if( ((bool)cs.ExtendedProperties["CS_IsIdentity"].Value) == true)
{
Response.Write(cs.Name);
}
}
%>
Table columns
CS_IsRowGuidCol
CS_IsIdentity
CS_IsComputed
CS_IsDeterministic
CS_IdentitySeed
CS_IdentityIncrement
CS_Default
CS_IsIdentity
CS_IsComputed
CS_IsDeterministic
CS_IdentitySeed
CS_IdentityIncrement
CS_Default
view columns
CS_IsComputed
CS_IsDeterministic
CS_IsDeterministic
command parameters
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 中的扩展属性的内容请参考联机丛书。