zoukankan      html  css  js  c++  java
  • CodeSmith实用技巧(四):使用扩展属性

     SchemaExplorer允许我们获取数据库中一些对象的信息。如果你使用的是SQL Server2000数据库,你可以通过扩展属性获取很多对象的有用的信息。例如:SQL Server定义了一个扩展属性来标识表中的唯一标识字段,在模版中可以这样写:
    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

    Table columns

     CS_IsRowGuidCol

     CS_IsIdentity

     CS_IsComputed

     CS_IsDeterministic

     CS_IdentitySeed

     CS_IdentityIncrement

     CS_Default

    view columns

     CS_IsComputed

     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 中的扩展属性的内容请参考联机丛书。

    支持TerryLee的创业产品Worktile
    Worktile,新一代简单好用、体验极致的团队协同、项目管理工具,让你和你的团队随时随地一起工作。完全免费,现在就去了解一下吧。
    https://worktile.com
  • 相关阅读:
    swift3.0 coreData的使用-日记本demo
    Objective-C plist文件与KVC 的使用
    swift3.0 CoreGraphics绘图-实现画板
    Objective-C 使用核心动画CAAnimation实现动画
    Objectiv-C UIKit基础 NSLayoutConstraint的使用(VFL实现)
    Objectiv-c
    C语言基础
    C语言基础
    swift 3.0 基础练习 面向对象 类的扩展
    myIsEqualToString
  • 原文地址:https://www.cnblogs.com/Terrylee/p/305618.html
Copyright © 2011-2022 走看看