初学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![]()
10
using System;
11
using System.Text;
12
using System.Data;
13
using System.Collections.Generic;
14
using Websharp.ORM.Base;
15
namespace <%=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![]()
<%@ 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

10
using System;11
using System.Text;12
using System.Data;13
using System.Collections.Generic;14
using Websharp.ORM.Base;15
namespace <%=NameSpace%>16
{17
public class <%=CurTbl%>Entity : IEntity18
{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


浙公网安备 33010602011771号