• 有关CodeBuilder中基础模板的说明


    CodeBuilder中的Template.FbBase是一个基于xml语法的基础模板,主要由defkeys、functions、parts、sections构成。

    代码
    <?xml version="1.0" encoding="utf-8" ?>
    <!-- 该文件由faib studio定义,版本为1.0 -->
    <!-- 
    language:生成的代码语言Sql|CSharpText等等
    convert:数据类型转换字典配置
    -->
    <config name="生成MSSQL脚本" language="Sql" convert="csconvert.config">
      
    <!-- 定义一些常量,这些常量也使用$key$进行引用 -->
      
    <defkeys>
        
    <key name="Author">Faib</key>
      
    </defkeys>
      
    <!--
      定义一些外部函数
      language:代码文件的语言类型 CSharp|VBasic
      file:代码文件
      
    -->
      
    <functions>
        
    <function name="ColumnSql" language="CSharp" file="code\sqlcolumn.cs" />
      
    </functions>
      
    <!-- 结构:parts\part\sections\section -->
      
    <!-- 注意调用顺序的定义 -->
      
    <parts>
        
    <part name="SQL" file="Design\create.sql" loop="None">
          
    <sections>
            
    <section name="TableCreate" loop="Tables">
              
    <sections>
                 
    <section name="ColumnArray" loop="Columns" endchar=",">
        [$ColumnName$] $GetColumnSql()$
    </section>
                 
    <section name="ColumDescript" loop="Columns">
    <![CDATA[$AddColumnDescription()$
    go
    ]]>
                 
    </section>
                 
    <section name="PrimaryCreate" loop="PrimaryKeys">
    <![CDATA[alter table $TableName$
        add constraint PK_$TableName$_$ColumnName$ primary key ($ColumnName$)
    go
    ]]>
                 
    </section>
              
    </sections>
              
    <body>
        
    <![CDATA[
    create table [$TableName$] ($ColumnArray$
    )
    go

    $PrimaryCreate$

    -- Region 添加说明
    $AddTableDescription()$
    go

    $ColumDescript$
    -- EndRegion
    ]]>
              
    </body>
            
    </section>
            
    <section name="ReferenceDelete" loop="Tables">
              
    <sections>
                 
    <section name="ReferenceDelete1" loop="RefObjects">
    <![CDATA[if exists (select 1
        from sysobjects
        where id = object_id('FK_$FKTableName$_$PKTableName$')
        and type = 'F')
            alter table $FKTableName$
            drop constraint FK_$FKTableName$_$PKTableName$
    go
    ]]>
                 
    </section>
              
    </sections>
              
    <body>
        
    <![CDATA[$ReferenceDelete1$]]>
              
    </body>
            
    </section>
            
    <section name="ReferenceCreate" loop="Tables">
              
    <sections>
                 
    <section name="ReferenceCreate1" loop="RefObjects">
    <![CDATA[alter table $FKTableName$
        add constraint FK_$FKTableName$_$PKTableName$ foreign key ($FKColumnName$)
            references $PKTableName$ ($PKColumnName$)
    go
    ]]>
                 
    </section>
              
    </sections>
              
    <body>
        
    <![CDATA[$ReferenceCreate1$]]>
              
    </body>
            
    </section>
            
    <section name="TableDelete" loop="Tables">
    <![CDATA[
    if exists (select 1
        from sysobjects
        where id = object_id('$TableName$')
        and type = 'U')
            drop table [$TableName$]
    go
    ]]>
            
    </section>
          
    </sections>
          
    <body>
            
    <![CDATA[
    -- =======================================================
    -- 本脚本由CodeBuilder工具生成
    -- 版权所有 (C) Faib Studio 2009
    --
    -- 创建人员: $Author$
    -- 创建时间: $Now$
    -- =======================================================

    -- Region 删除关系
    $ReferenceDelete$
    -- End Region

    -- Region 删除表
    $TableDelete$
    -- End Region

    -- Region 创建表
    $TableCreate$
    -- End Region

    -- Region 创建关系
    $ReferenceCreate$
    -- End Region
    ]]>
          
    </body>
        
    </part>
      
    </parts>
    </config>
  • 相关阅读:
    完美主义之我见
    职场-位置思维
    我的读书观
    人力资源是组织的第一战略资源-论基层员工
    积累是做成事情得唯一途径
    地理信息数据处理之我见
    word 之 插入删除空行
    OSMeteorTranslationAPI(百度,有道)对比
    CsharpOSMeteorCodeGenerator(Metero代码生成器)
    HtmlDOM 文档读取研究
  • 原文地址:https://www.cnblogs.com/faib/p/1658000.html
Copyright © 2020-2023  润新知