初学Codesmith,第一次写模板

  居然跑通了,乐。
 留个纪念。
 1<%@ CodeTemplate Language="C#" TargetLanguage="C#" Src="" Inherits="" Debug="False" Description="Template description here." %>
 2<%@ Assembly Name="System.Data" %>
 3<%@ Assembly Name="SchemaExplorer" %>
 4<%@ Import Namespace="System.Data" %>
 5<%@ Assembly Name="SchemaExplorer" %>
 6<%@ Property Name="NameSpace" Type="System.string" Default="" Optional="False" Category="" Description="" Editor="" EditorBase="" Serializer="" %>
 7<%@ Property Name="CurDB" Type="SchemaExplorer.DatabaseSchema" Default="" Optional="False" Category="" Description="" Editor="" EditorBase="" Serializer="" %>
 8<%@ Property Name="CurTbl" Type="SchemaExplorer.TableSchema" Default="" Optional="False" Category="" Description="" Editor="" EditorBase="" Serializer="" %>
 9
10using System;
11using System.Text;
12using System.Data;
13using System.Collections.Generic;
14using Websharp.ORM.Base;
15namespace <%=NameSpace%>
16{
17    public class <%=CurTbl%>Entity : IEntity
18    {
19        public <%=CurTbl%>Entity()
20        {
21         }
22        <% foreach(SchemaExplorer.ColumnSchema col in CurTbl.Columns) {%>
23       
24         <%=GetCode(col)%>
25        <%}%>
26        
27     }
28    
29
30}
31
32<script runat="template">
33
34 private string GetCode(SchemaExplorer.ColumnSchema col)
35{
36    string strCode = col.DataType + " m_"+col.Name+";\r\n";
37    strCode  +="        public ";
38    strCode += (col.DataType+" "+col.Name+"{\r\n");
39    strCode +="          get {\r\n           return "+"m_"+col.Name+";\r\n              }\r\n            }";
40    return strCode;
41 }
42
43</script>
44
45
46
posted @ 2006-09-01 16:28  彷徨......  阅读(295)  评论(1)    收藏  举报