可以针对任意数据库,根据模板生成代码,支持插件(个人认为比较好玩的插件方式)。
1 <%TempletName%>=TEntity
2 <%FolderName%>=
3 <%FileName%>=<%ns%>.<%FixTblName%>.cs
4 <%Foreach%>=true
5 <%IgnoreColumns%>=ID
6 <%TMacro%>:<%FixTblName%>=CodeGenHelper.Test1(<%tn%>)
7 <%CMacro%>:<%FixColName%>=CodeGenHelper.Test1(<%cn%>)
8 <%Begin%>
9
10 using System;
11 using System.Collections.Generic;
12 using System.Text;
13 using System.Data;
14 using Fx.Common.Data;
15 using Fx.Common.DataAccess;
16 using Fx.Common.Rule;
17 using Fx.Common.Exceptions;
18
19 using Cy.Common.Pos.Data;
20 using Cy.Common.Pos.DataAccess;
21 using Cy.Common.Card;
22 using Cy.Common.Ticket;
23 using Fx.Common.Context;
24 using Fx.Common.Base;
25 using Cy.Common.Shift;
26
27 namespace <%ns%>
28 {
29 [TableMapping("<%tn%>", CoIdPrefix = "<%tn%>")]
30 public partial class T<%FixTblName%> : TEntity
31 {
32 //---------------------------------------------------------------------
33 static T<%FixTblName%>()
34 {
35 Type type = typeof(T<%FixTblName%>);
36 TEntity.RegisterClass(type);
37 }
38 //---------------------------------------------------------------------
39 public T<%FixTblName%>()
40 {
41 }
42 //---------------------------------------------------------------------
43 public T<%FixTblName%>(TContext ctx):base(ctx)
44 {
45 }
46 //---------------------------------------------------------
47 public override TDataAccess CreateDataAccess()
48 {
49 return new T<%FixTblName%>Access ();
50 }
51 //---------------------------------------------------------
52 public new T<%FixTblName%>Access DataAccess
53 {
54 get { return base.DataAccess as T<%FixTblName%>Access;}
55 }
56 //---------------------------------------------------------------
57 public override void Save()
58 {
59 if(IsDirty)
60 base.Save();
61 }
62 //---------------------------------------------------------------
63 #region Properties
64 <%cr%>
65 //---------------------------------------------------------------------
66 protected <%clsDT%> m_<%FixColName%>;
67 [Mapping("<%cn%>")]
68 [Assign]
69 [Compare]
70 public <%clsDT%> <%FixColName%>
71 {
72 get { return m_<%FixColName%>; }
73 set { m_<%FixColName%> = value; }
74 }
75 <%ecr%>
76 //---------------------------------------------------------------------
77 #endregion
78 }
79 }
根据上面模板生成的代码如下:
1
2 using System;
3 using System.Collections.Generic;
4 using System.Text;
5 using System.Data;
6 using Fx.Common.Data;
7 using Fx.Common.DataAccess;
8 using Fx.Common.Rule;
9 using Fx.Common.Exceptions;
10
11 using Cy.Common.Pos.Data;
12 using Cy.Common.Pos.DataAccess;
13 using Cy.Common.Card;
14 using Cy.Common.Ticket;
15 using Fx.Common.Context;
16 using Fx.Common.Base;
17 using Cy.Common.Shift;
18
19 namespace xxx
20 {
21 [TableMapping("ADJUST", CoIdPrefix = "ADJUST")]
22 public partial class TAdjust : TEntity
23 {
24 //---------------------------------------------------------------------
25 static TAdjust()
26 {
27 Type type = typeof(TAdjust);
28 TEntity.RegisterClass(type);
29 }
30 //---------------------------------------------------------------------
31 public TAdjust()
32 {
33 }
34 //---------------------------------------------------------------------
35 public TAdjust(TContext ctx):base(ctx)
36 {
37 }
38 //---------------------------------------------------------
39 public override TDataAccess CreateDataAccess()
40 {
41 return new TAdjustAccess ();
42 }
43 //---------------------------------------------------------
44 public new TAdjustAccess DataAccess
45 {
46 get { return base.DataAccess as TAdjustAccess;}
47 }
48 //---------------------------------------------------------------
49 public override void Save()
50 {
51 if(IsDirty)
52 base.Save();
53 }
54 //---------------------------------------------------------------
55 #region Properties
56
57 //---------------------------------------------------------------------
58 protected System.Int32? m_Aindex;
59 [Mapping("AINDEX")]
60 [Assign]
61 [Compare]
62 public System.Int32? Aindex
63 {
64 get { return m_Aindex; }
65 set { m_Aindex = value; }
66 }
67
68 //---------------------------------------------------------------------
69 protected System.String m_Title;
70 [Mapping("TITLE")]
71 [Assign]
72 [Compare]
73 public System.String Title
74 {
75 get { return m_Title; }
76 set { m_Title = value; }
77 }
78
79 //---------------------------------------------------------------------
80 protected System.Int32? m_BillTypeNo;
81 [Mapping("BILL_TYPE_NO")]
82 [Assign]
83 [Compare]
84 public System.Int32? BillTypeNo
85 {
86 get { return m_BillTypeNo; }
87 set { m_BillTypeNo = value; }
88 }
89
90 //---------------------------------------------------------------------
91 protected System.String m_BillCode;
92 [Mapping("BILL_CODE")]
93 [Assign]
94 [Compare]
95 public System.String BillCode
96 {
97 get { return m_BillCode; }
98 set { m_BillCode = value; }
99 }
100
101 //---------------------------------------------------------------------
102 protected System.String m_StoreId;
103 [Mapping("STORE_ID")]
104 [Assign]
105 [Compare]
106 public System.String StoreId
107 {
108 get { return m_StoreId; }
109 set { m_StoreId = value; }
110 }
111
112 //---------------------------------------------------------------------
113 protected System.DateTime? m_AdjustDate;
114 [Mapping("ADJUST_DATE")]
115 [Assign]
116 [Compare]
117 public System.DateTime? AdjustDate
118 {
119 get { return m_AdjustDate; }
120 set { m_AdjustDate = value; }
121 }
122
123 //---------------------------------------------------------------------
124 protected System.Int32? m_StateNo;
125 [Mapping("STATE_NO")]
126 [Assign]
127 [Compare]
128 public System.Int32? StateNo
129 {
130 get { return m_StateNo; }
131 set { m_StateNo = value; }
132 }
133
134 //---------------------------------------------------------------------
135 protected System.Int32? m_AdjustDbTarget;
136 [Mapping("ADJUST_DB_TARGET")]
137 [Assign]
138 [Compare]
139 public System.Int32? AdjustDbTarget
140 {
141 get { return m_AdjustDbTarget; }
142 set { m_AdjustDbTarget = value; }
143 }
144
145 //---------------------------------------------------------------------
146 protected System.String m_Amemo;
147 [Mapping("AMEMO")]
148 [Assign]
149 [Compare]
150 public System.String Amemo
151 {
152 get { return m_Amemo; }
153 set { m_Amemo = value; }
154 }
155
156 //---------------------------------------------------------------------
157 protected System.Int32? m_SychorStateNo;
158 [Mapping("SYCHOR_STATE_NO")]
159 [Assign]
160 [Compare]
161 public System.Int32? SychorStateNo
162 {
163 get { return m_SychorStateNo; }
164 set { m_SychorStateNo = value; }
165 }
166
167 //---------------------------------------------------------------------
168 protected System.String m_BillorId;
169 [Mapping("BILLOR_ID")]
170 [Assign]
171 [Compare]
172 public System.String BillorId
173 {
174 get { return m_BillorId; }
175 set { m_BillorId = value; }
176 }
177
178 //---------------------------------------------------------------------
179 protected System.DateTime? m_BillTime;
180 [Mapping("BILL_TIME")]
181 [Assign]
182 [Compare]
183 public System.DateTime? BillTime
184 {
185 get { return m_BillTime; }
186 set { m_BillTime = value; }
187 }
188
189 //---------------------------------------------------------------------
190 protected System.String m_CheckerId;
191 [Mapping("CHECKER_ID")]
192 [Assign]
193 [Compare]
194 public System.String CheckerId
195 {
196 get { return m_CheckerId; }
197 set { m_CheckerId = value; }
198 }
199
200 //---------------------------------------------------------------------
201 protected System.DateTime? m_CheckTime;
202 [Mapping("CHECK_TIME")]
203 [Assign]
204 [Compare]
205 public System.DateTime? CheckTime
206 {
207 get { return m_CheckTime; }
208 set { m_CheckTime = value; }
209 }
210
211 //---------------------------------------------------------------------
212 protected System.String m_CreatorId;
213 [Mapping("CREATOR_ID")]
214 [Assign]
215 [Compare]
216 public System.String CreatorId
217 {
218 get { return m_CreatorId; }
219 set { m_CreatorId = value; }
220 }
221
222 //---------------------------------------------------------------------
223 protected System.DateTime? m_CreateTime;
224 [Mapping("CREATE_TIME")]
225 [Assign]
226 [Compare]
227 public System.DateTime? CreateTime
228 {
229 get { return m_CreateTime; }
230 set { m_CreateTime = value; }
231 }
232
233 //---------------------------------------------------------------------
234 protected System.String m_ModifierId;
235 [Mapping("MODIFIER_ID")]
236 [Assign]
237 [Compare]
238 public System.String ModifierId
239 {
240 get { return m_ModifierId; }
241 set { m_ModifierId = value; }
242 }
243
244 //---------------------------------------------------------------------
245 protected System.DateTime? m_ModifyTime;
246 [Mapping("MODIFY_TIME")]
247 [Assign]
248 [Compare]
249 public System.DateTime? ModifyTime
250 {
251 get { return m_ModifyTime; }
252 set { m_ModifyTime = value; }
253 }
254
255 //---------------------------------------------------------------------
256 protected System.String m_UnCheckerId;
257 [Mapping("UN_CHECKER_ID")]
258 [Assign]
259 [Compare]
260 public System.String UnCheckerId
261 {
262 get { return m_UnCheckerId; }
263 set { m_UnCheckerId = value; }
264 }
265