BusinessObject.cst 实体类生成模板

 1<%-- 
 2Name:实体类生成模板
 3Author: 吴碧宇
 4Description: 根据数据库中的表生成一个实体类
 5--%>
 6<%@ CodeTemplate Language="C#" ResponseEncoding="UTF-8" TargetLanguage="Text" Src="Helper.cs" Inherits="Helper" Debug="False" Description="Template description here." %>
 7<%-- 程序集--%>
 8<%@ Assembly Name="System.Data" %>
 9<%@ Assembly Name="SchemaExplorer" %>
10<%@ Assembly Name="CodeSmith.CustomProperties" %>
11<%@ Assembly Name="CodeSmith.BaseTemplates" %>
12<%--导入命名空间 --%>
13<%@ Import Namespace="System.Data" %>
14<%@ Import Namespace="System.Text" %>
15<%@ Import Namespace="SchemaExplorer" %>
16<%--定义属性 --%>
17<%@ Property Name="NameSpace" Type="System.String" Default="" Optional="False" Category="命名空间" Description="当前生成实体类的命名空间"  %>
18<%@ Property Name="Table" Type="SchemaExplorer.TableSchema" Default="" Optional="False" Category="数据库表对象" Description="实体类对应的表对象" Editor="" EditorBase="" Serializer="" %>
19using System;
20using System.Collections.Generic;
21using System.Text;
22
23namespace <%=NameSpace%>.Framework
24{
25    /// <summary>
26    ///<%
27    if(Table.ExtendedProperties["Rmark"] != null)

28    {
29        Response.WriteLine(Table.ExtendedProperties["Rmark"].Value.ToString());
30    }

31    else
32    {
33        Response.WriteLine("生成时请在数据库中的扩展属性中设置key=Rmark,Value=''");
34    }
%>    /// </summary>
35    [Serializable()]
36    public partial class <%= GetClassName(Table)%>
37    {
38        <%
39        foreach(ColumnSchema column in Table.Columns)
40        {
41        %>
42        private <%= GetCSharpVariableType(column)%> <%=GetFiledName(column)%>//<%= column.Description%>
43        <%
44        }

45        %>
46        
47        public <%= GetClassName(Table)%>()
48        {
49        
50        }

51        
52        <%
53        foreach(ColumnSchema column in Table.Columns)
54        {
55        %>
56        /// <summary>
57        ///  <%= column.Description%>
58        /// </summary>

59        public <%= GetCSharpVariableType(column)%> <%=GetPropertyName(column)%>
60        {
61            get return <%=GetFiledName(column)%>; }
62            set <%=GetFiledName(column)%> = value; }
63        }

64        
65        <%
66        }

67        %>
68        
69    }

70}

71<script runat="template">
72
73
74</script>
posted @ 2007-07-05 19:48  吴碧宇  阅读(678)  评论(1编辑  收藏  举报