IMZRH的日志

努力成为一个有用的人

导航

推荐一个生成实体类的CodeSmith模板

Posted on 2007-10-12 23:15  张荣华  阅读(2802)  评论(4编辑  收藏  举报
  在做项目的时候,我们经常会把数据库中的表生成对应的实体类。如果数据库中的表很多,这个工作就会变得
枯燥无味而又浪费时间,这时我们就可以利用一些代码自动生成工具来完成这个工作。下面我就推荐一个codesmith
模板
它生成的格式如下:
  1 using System;
  2 using System.Data;
  3 using System.Collections.Generic;
  4 using System.Text;
  5 
  6 namespace Model
  7 {
  8     /// <summary>
  9     /// This object represents the properties of a BDZ_JCXX.
 10     ///Create Date: 2007-10-12 23:09:17
 11     ///Author: 张荣华
 12     /// </summary>        
 13     [Serializable]
 14     public class BDZ_JCXXInfo
 15     {
 16 
 17         #region 变量声明
 18         //声明私有变量 
 19         private int _iD;
 20         private string _bDZM;
 21         private int _dYDJ;
 22         private double _rL;
 23         private int _tS;
 24         private string _eDDL;
 25         private int _dQ_ID;
 26         private int _gS_ID;
 27         private int _yXD_ID;
 28         private DateTime _sCRQ;
 29         private int _sCRY_ID;
 30         private string _bZ;
 31 
 32         #endregion
 33 
 34         #region 构造函数
 35         /// <summary> 
 36         ///默认构造函数 
 37         /// </summary> 
 38         public BDZ_JCXXInfo()
 39         {
 40         }
 41 
 42         /// <summary> 
 43         ///只带主键的构造函数
 44         /// </summary> 
 45         /// <param name="ID">序号</param>
 46         public BDZ_JCXXInfo(int iD)
 47         {
 48             this._iD = iD;
 49 
 50         }
 51 
 52         /// <summary> 
 53         ///全参的构造函数
 54         /// </summary> 
 55         /// <param name="ID">序号</param>
 56         /// <param name="BDZM">变电站名</param>
 57         /// <param name="DYDJ">电压等级</param>
 58         /// <param name="RL">容量</param>
 59         /// <param name="TS">台数</param>
 60         /// <param name="EDDL">额定电流</param>
 61         /// <param name="DQ_ID">所属地区ID</param>
 62         /// <param name="GS_ID">所属公司ID</param>
 63         /// <param name="YXD_ID">所属运行队ID</param>
 64         /// <param name="SCRQ">删除日期</param>
 65         /// <param name="SCRY_ID">删除人员ID</param>
 66         /// <param name="BZ">备注</param>
 67         public BDZ_JCXXInfo(int iD, string bDZM, int dYDJ, double rL, int tS, string eDDL, int dQ_ID, int gS_ID, int yXD_ID, DateTime sCRQ, int sCRY_ID, string bZ)
 68         {
 69             this._iD = iD;
 70             this._bDZM = bDZM;
 71             this._dYDJ = dYDJ;
 72             this._rL = rL;
 73             this._tS = tS;
 74             this._eDDL = eDDL;
 75             this._dQ_ID = dQ_ID;
 76             this._gS_ID = gS_ID;
 77             this._yXD_ID = yXD_ID;
 78             this._sCRQ = sCRQ;
 79             this._sCRY_ID = sCRY_ID;
 80             this._bZ = bZ;
 81 
 82         }
 83 
 84         #endregion
 85 
 86         #region 属性
 87         //序号属性
 88         public int ID
 89         {
 90             get
 91             {
 92                 return _iD;
 93             }
 94             set
 95             {
 96                 _iD = value;
 97             }
 98         }
 99 
100         //变电站名属性
101         public string BDZM
102         {
103             get
104             {
105                 return _bDZM;
106             }
107             set
108             {
109                 _bDZM = value;
110             }
111         }
112 
113         //电压等级属性
114         public int DYDJ
115         {
116             get
117             {
118                 return _dYDJ;
119             }
120             set
121             {
122                 _dYDJ = value;
123             }
124         }
125 
126         //容量属性
127         public double RL
128         {
129             get
130             {
131                 return _rL;
132             }
133             set
134             {
135                 _rL = value;
136             }
137         }
138 
139         //台数属性
140         public int TS
141         {
142             get
143             {
144                 return _tS;
145             }
146             set
147             {
148                 _tS = value;
149             }
150         }
151 
152         //额定电流属性
153         public string EDDL
154         {
155             get
156             {
157                 return _eDDL;
158             }
159             set
160             {
161                 _eDDL = value;
162             }
163         }
164 
165         //所属地区ID属性
166         public int DQ_ID
167         {
168             get
169             {
170                 return _dQ_ID;
171             }
172             set
173             {
174                 _dQ_ID = value;
175             }
176         }
177 
178         //所属公司ID属性
179         public int GS_ID
180         {
181             get
182             {
183                 return _gS_ID;
184             }
185             set
186             {
187                 _gS_ID = value;
188             }
189         }
190 
191         //所属运行队ID属性
192         public int YXD_ID
193         {
194             get
195             {
196                 return _yXD_ID;
197             }
198             set
199             {
200                 _yXD_ID = value;
201             }
202         }
203 
204         //删除日期属性
205         public DateTime SCRQ
206         {
207             get
208             {
209                 return _sCRQ;
210             }
211             set
212             {
213                 _sCRQ = value;
214             }
215         }
216 
217         //删除人员ID属性
218         public int SCRY_ID
219         {
220             get
221             {
222                 return _sCRY_ID;
223             }
224             set
225             {
226                 _sCRY_ID = value;
227             }
228         }
229 
230         //备注属性
231         public string BZ
232         {
233             get
234             {
235                 return _bZ;
236             }
237             set
238             {
239                 _bZ = value;
240             }
241         }
242 
243         #endregion
244     }
245 }
246 
247 
248