zoukankan      html  css  js  c++  java
  • CodeSmith(5)访问数据库

    <%@ CodeTemplate Language="C#" Inherits="CodeSmith.BaseTemplates.SqlCodeTemplate" TargetLanguage="T-SQL" Description="Generates SELECT/INSERT/UPDATE/DELETE stored procedure based on a database schema." %>
    <%@ Property Name="SourceDatabase" Type="SchemaExplorer.DatabaseSchema" Category="Context" Description="Database that the stored procedures should be based on." %>
    <%@ Assembly Name="SchemaExplorer" %>
    <%@ Assembly Name="CodeSmith.BaseTemplates" %>
    <%@ Import Namespace="SchemaExplorer" %>
    <%
    for (int i = 0; i < SourceDatabase.Tables.Count; i++)
    {
        
            Response.WriteLine(
    "-- Skipping " + SourceDatabase.Tables[i].Name );
        

    }

    %>
    主要是引用<%@ Assembly Name="SchemaExplorer" %>
    <%@ Assembly Name="CodeSmith.BaseTemplates" %>
    <%@ Import Namespace="SchemaExplorer" %>程序集。
    之后声明个属性Type为SchemaExplorer.DatabaseSchema的属性(数据库).
    之后根据SourceDatabase.Tables:即得到该数据库的所有的表的集合,
    SourceDatabase.Tables.Count:得到数据库表的数量
    SourceDatabase.Tables[i]:得到第i个表
    SourceDatabase.Tables[i].Name:得到第i个表的表名
  • 相关阅读:
    Webservice接口
    Loadrunner使用代理录制
    Python学习Collections 模块
    Python学习笔记(八)
    Linux系统部署禅道
    Python学习笔记(七)
    Python学习笔记(六)
    Python学习笔记(五)
    Python学习笔记(四)
    Python学习笔记(三)
  • 原文地址:https://www.cnblogs.com/luluping/p/1338210.html
Copyright © 2011-2022 走看看