<%@ 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个表的表名