下边以.net开发的三层结构进行描述:
分别贴上了实体层,数据库访问层,业务逻辑层
实体层(model层 or entity层):
<%@ CodeTemplate Language="C#" TargetLanguage="Text" Src="" Inherits="" Debug="False" Description="Template description here." %>
<%@ Assembly Name="SchemaExplorer" %>
<%@ Assembly Name="System.Data" %>
<%@ Property Name="TargetTable" Type="SchemaExplorer.TableSchema" Category="Context" Description="TargetTable that the object is based on." %>
<%@ Property Name="Author" Type="System.String" Default="Xiao ChangJian" Category="Context" Description="The author for this procedure." %>
<%@ Property Name="NameSpace" Type="System.String" Default="MySpace" Category="Context" Description="TargetTable that the object is based on." %>
<%@ Property Name="Description" Type="System.String" Default="" Category="Context" Description="The description for this procedure."%>
<%@ Map Name="CSharpAlias" Src="System-CSharpAlias" Description="System to C# Type Map" %>
<%@ Import Namespace="SchemaExplorer" %>
<%@ Import Namespace="System.Data" %>
/* ----------------------------------------------------------------------
* File Name: <%= GetTableName(TargetTable) %>Model.cs
*
* Create Author: <%= Author %>
*
* Create DateTime: <%=DateTime.Now.ToShortDateString() %>
*
* Description: <%= Description %>
*----------------------------------------------------------------------*/
using System;
namespace <%= NameSpace %>
{
[Serializable()]
public class <%= GetTableName(TargetTable) %>Model
{
<% foreach (ColumnSchema column in TargetTable.Columns){ %>
///<summary>
///<%=column.Description %>
///</summary>
public <%= CSharpAlias[column.SystemType.FullName] %> <%= column.Name %> { get; set; }
<% } %>
}
}
<script runat="template">
//Get tablename
public string GetTableName(TableSchema table)
{
if(table==null)
{
return null;
}
return table.Name ;
}
</script>