BusinessObject.cst 实体类生成模板
1
<%--
2
Name:实体类生成模板
3
Author: 吴碧宇
4
Description: 根据数据库中的表生成一个实体类
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="" %>
19
using System;
20
using System.Collections.Generic;
21
using System.Text;
22![]()
23
namespace <%=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>

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74
