codesmith怎麼判斷sqlserver數據庫字段是否是標識自增字段

使用ExtendedProperty擴展信息判斷

CS_isIdentity:是否爲標識符,不支持Access

CS_isComputed:是否爲計算列

CS_isDeterministic:是否肯定...

CS_IdentitySeed::標識列種子數

CS_IdentityIncrement:標識列遞增量

CS_Default:列的默認值 

CS_isRowGuidCol

例子:

<% 
foreach(ColumnSchema cs in SourceTable.Columns) {  
if( ((bool)cs.ExtendedProperties["CS_IsIdentity"].Value) == true)
{
Response.Write(cs.Name);
}
}
%>ui

 

我是這麼判斷的

if(TargetTable.PrimaryKeys.IsSynchronized||TargetTable.PrimaryKeys.IsReadOnly)
{
  //表示是自增加的
}.net

 

出處:http://bbs.csdn.net/topics/300035927rem

我我的認爲仍是使用ExtendedProperties["CS_IsIdentity"].Value 比較準確點。get

相關文章
相關標籤/搜索