entity.cst
<%--引用%>
<%@ CodeTemplate Language="C#" TargetLanguage="Text" Description="Template description here." %>
<%@ Assembly Name="SchemaExplorer" %>
<%@ Import Namespace="SchemaExplorer" %>
<%@ Assembly Name="CodeTemplateRule" %>
<%@ Import Namespace="CodeTemplateRule" %>
<%--模板属性%>
<%@ Property Name="DataBase" Type="SchemaExplorer.DatabaseSchema" Category="Context" Description="数据库连接." %>
<%@ Property Name="TableName" Type="System.String" Default="" Optional="False" Category="" Description="表名" %>
<%@ Property Name="NameSpace" Type="System.String" Default="Company.Product.Module" Optional="False" Category="" Description="命名空间" %>
<%@ Property Name="Author" Type="System.String" Default="Author" Optional="False" Category="" Description="作者" %>
<%@ Property Name="Description" Type="System.String" Default="实体类" Optional="False" Category="" Description="该类的描述" %>
<script runat="template">
CodeTemplateRule rule=new CodeTemplateRule();
</script>
using System;
namespace <%= NameSpace %>
{
/// <summary>
/// 作用:<%= Description %>
/// 作者:<%= Author %>
/// 日期:<%= DateTime.Now.ToString() %>
///</summary>
public class <%= rule.GetTableName(TableName) %>Entity
{
/// <summary>
/// 构造函数
///</summary>
public <%= rule.GetTableName(TableName) %>Entity()
{
}
<%
//局部变量
ColumnSchemaCollection columns=rule.GetColumnCollection(DataBase,TableName);
for(int i=0;i<columns.Count;i++)
{
Response.Write(" //"+columns[i].Description+"\r\n");
Response.Write(" private "+rule.GetType(columns[i])+" m_"+columns[i].Name+";\r\n");
}
%>
<%
//属性
for(int i=0;i<columns.Count;i++)
{
%>
///<summary>
///<%= columns[i].Description %>
///</summary>
public <%= rule.GetType(columns[i]) %> <%= columns[i].Name %>
{
get
{
return m_<%= columns[i].Name %>;
}
set
{
m_<%= columns[i].Name %>=value;
}
}
<%
}
%>
}
}