-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBLL.cst
184 lines (167 loc) · 6.29 KB
/
BLL.cst
1
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
<%@ CodeTemplate Language="C#" TargetLanguage="C#" ResponseEncoding="UTF-8" Src="ToolsCodeTemplate.cs" Inherits="ToolsCodeTemplate"%>
<%@ Property Name="TargetTable" Type="SchemaExplorer.TableSchema" Category="Context" Description="TargetTable that the object is based on." %>
<%@ Property Name="ModelsNamespace" Default="MyOffice.Models" Type="System.String" Category="Context" Description="TargetTable that the object is based on." %>
<%@ Property Name="DALNamespace" Default="MyOffice.DAL" Type="System.String" Category="Context" Description="TargetTable that the object is based on." %>
<%@ Property Name="BLLNamespace" Default="MyOffice.BLL" Type="System.String" Category="Context" Description="TargetTable that the object is based on." %>
<%@ Property Name="BLLClassNameSurfix" Default="Manager" Type="System.String" Category="Context" Description="TargetTable that the object is based on." %>
<%@ Property Name="DALClassNameSurfix" Default="Service" Type="System.String" Category="Context" Description="TargetTable that the object is based on." %>
<%@ Assembly Name="SchemaExplorer" %>
<%@ Assembly Name="System.Data" %>
<%@ Import Namespace="SchemaExplorer" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Text.RegularExpressions" %>
using System;
using System.Collections.Generic;
using System.Text;
using System.ComponentModel;
using <%= DALNamespace %>;
using <%= ModelsNamespace %>;
namespace <%= BLLNamespace %>
{
[DataObject]
public partial class <%= GetBLLClassName() %>
{
#region 根据传入Model,并返回Model
/// <summary>
/// 根据传入Model,并返回是否插入成功。
/// </summary>
[DataObjectMethod(DataObjectMethodType.Insert)]
public static bool <%= GetModelClassName() %>Insert(<%= GetModelClassName() %> <%= GetModelParamName() %>)
{
return new <%= GetDALClassName() %>().Insert(<%= GetModelParamName() %>);
}
#endregion
#region 根据Id删除数据记录
/// <summary>
/// 根据Id删除数据记录
/// </summary>
[DataObjectMethod(DataObjectMethodType.Delete)]
public int DeleteBy<%= GetPKPropertyName() %>(<%= GetPKPropertyType() %> <%= GetPKParamName() %>)
{
return new <%= GetDALClassName() %>().DeleteBy<%= GetPKPropertyName() %>(<%= GetPKParamName() %>);
}
#endregion
#region 根据字段名获取数据记录
/// <summary>
/// 根据字段名获取数据记录
/// </summary>
public static IEnumerable<<%= GetModelClassName() %>> GetBycolumnName(string columnName,string columnContent)
{
return new <%= GetDALClassName() %>().GetBycolumnName(columnName,columnContent);
}
#endregion
#region 根据字段名获取数据记录
/// <summary>
/// 根据字段名获取数据记录
/// </summary>
public static IEnumerable<<%= GetModelClassName() %>> GetBycolumnNames(string[] columnNames,string[] columnContents)
{
return new <%= GetDALClassName() %>().GetBycolumnNames(columnNames,columnContents);
}
#endregion
#region 根据传入Model更新数据并返回更新后的Model
/// <summary>
/// 根据传入Model的对应数据库主键更新数据并返回受影响的行数
/// </summary>
[DataObjectMethod(DataObjectMethodType.Update)]
public static int Update(<%= GetModelClassName() %> <%= GetModelParamName() %>)
{
return new <%= GetDALClassName() %>().Update(<%= GetModelParamName() %>);
}
#endregion
#region 传入Id,获得Model实体
/// <summary>
/// 传入Id,获得Model实体
/// </summary>
[DataObjectMethod(DataObjectMethodType.Select)]
public static <%= GetModelClassName() %> GetBy<%= GetPKPropertyName() %>(<%= GetPKPropertyType() %> <%= GetPKParamName() %>)
{
return new <%= GetDALClassName() %>().GetBy<%= GetPKPropertyName() %>(<%= GetPKParamName() %>);
}
#endregion
#region 获得总记录数
///<summary>
/// 获得总记录数
///</summary>
public int GetTotalCount()
{
return new <%= GetDALClassName() %>().GetTotalCount();
}
#endregion
#region 获得分页记录集IEnumerable<>
///<summary>
/// 获得分页记录集IEnumerable<>
///</summary>
[DataObjectMethod(DataObjectMethodType.Select)]
public static IEnumerable<<%= GetModelClassName() %>> GetPagedData(int minrownum,int maxrownum)
{
return new <%= GetDALClassName() %>().GetPagedData(minrownum,maxrownum);
}
#endregion
#region 获得总记录集IEnumerable<>
///<summary>
/// 获得总记录集IEnumerable<>
///</summary>
[DataObjectMethod(DataObjectMethodType.Select)]
public static IEnumerable<<%= GetModelClassName() %>> GetAll()
{
return new <%= GetDALClassName() %>().GetAll();
}
#endregion
}
}
<script runat="template">
///////////////////////////////////////////////////////////////
// CLASS NAME by Shen Bo
///////////////////////////////////////////////////////////////
public string GetBLLClassName()
{
return GetModelClassName() + BLLClassNameSurfix;
}
public string GetDALClassName()
{
return GetModelClassName() + DALClassNameSurfix;
}
public string GetModelMemberVarName()
{
return GetModelParamName();
}
public string GetModelParamName()
{
return ConvertToCamel(GetModelClassName());
}
public string GetModelClassName()
{
return GetModelClassName(TargetTable);
}
///////////////////////////////////////////////////////////////
// PRIMARY KEY TYPE by Shen Bo
///////////////////////////////////////////////////////////////
public string GetPKPropertyType()
{
return GetPKType(TargetTable);
}
///////////////////////////////////////////////////////////////
// PRIMARY KEY NAME by Shen Bo
///////////////////////////////////////////////////////////////
public string GetPKPropertyName()
{
return ConvertToPascal(GetPKName());
}
public string GetPKMemberVarName()
{
return ConvertToCamel(GetPKName());
}
public string GetPKParamName()
{
return GetPKMemberVarName();
}
public string GetPKName()
{
return GetPKName(TargetTable);
}
public override string GetFileName()
{
return this.GetBLLClassName() + ".cs";
}
</script>