首页 新闻 搜索 专区 学院

Model层代码疑惑,求指教

0
悬赏园豆:20 [已解决问题] 解决于 2011-04-26 15:10
View Code
1 #region Fields
2 private short _uSER_STATUS;
3 private DateTime _lAST_LOGIN_TIME;
4 private decimal _uSER_GROUP_ID;
5 private string _uSER_ID = String.Empty;
6 private decimal _uSER_NM;
7 private short _uSER_TYPE;
8 private string _uSER_NAME = String.Empty;
9 private string _uSER_PWD = String.Empty;
10 private string _uSER_PWD_QUT = String.Empty;
11 private string _uSER_PWD_ANS = String.Empty;
12 private DateTime _uSER_BRI_DATE;
13 private short _uSER_SEX;
14 private string _uSER_TEL = String.Empty;
15 private string _uSER_EMAIL = String.Empty;
16 private string _uSER_INTRODUCE = String.Empty;
17 private string _uSER_IP = String.Empty;
18 private string _uSER_PROXY_IP = String.Empty;
19 private string _rEMARK = String.Empty;
20 private decimal _uSER_BUSINESS_NM;
21 private decimal _cOURSE_ONLINE;
22 private decimal _oTHER_ID;
23 private int _tOP_GROUP_ID;
24 private int _uSER_FLAG;
25 private int _lOGIN_TIMES;
26 private string _oTHER_ID_1 = String.Empty;
27 private string _oTHER_ID_2 = String.Empty;
28 private string _oTHER_ID_3 = String.Empty;
29 private string _oTHER_ID_4 = String.Empty;
30 private string _oTHER_ID_5 = String.Empty;
31 private string userGroupName;
32 private string _mobileno;
33 #endregion
34
35 #region Contructors
36 public USERSInfo()
37 {
38 }
39
40 public USERSInfo
41 (
42 short uSER_STATUS,
43 DateTime lAST_LOGIN_TIME,
44 decimal uSER_GROUP_ID,
45 string uSER_ID,
46 decimal uSER_NM,
47 short uSER_TYPE,
48 string uSER_NAME,
49 string uSER_PWD,
50 string uSER_PWD_QUT,
51 string uSER_PWD_ANS,
52 DateTime uSER_BRI_DATE,
53 short uSER_SEX,
54 string uSER_TEL,
55 string uSER_EMAIL,
56 string uSER_INTRODUCE,
57 string uSER_IP,
58 string uSER_PROXY_IP,
59 string rEMARK,
60 decimal uSER_BUSINESS_NM,
61 decimal cOURSE_ONLINE,
62 decimal oTHER_ID,
63 int tOP_GROUP_ID,
64 int uSER_FLAG,
65 int lOGIN_TIMES,
66 string oTHER_ID_1,
67 string oTHER_ID_2,
68 string oTHER_ID_3,
69 string oTHER_ID_4,
70 string oTHER_ID_5,
71 string mobileno
72
73 )
74 {
75 _uSER_STATUS = uSER_STATUS;
76 _lAST_LOGIN_TIME = lAST_LOGIN_TIME;
77 _uSER_GROUP_ID = uSER_GROUP_ID;
78 _uSER_ID = uSER_ID;
79 _uSER_NM = uSER_NM;
80 _uSER_TYPE = uSER_TYPE;
81 _uSER_NAME = uSER_NAME;
82 _uSER_PWD = uSER_PWD;
83 _uSER_PWD_QUT = uSER_PWD_QUT;
84 _uSER_PWD_ANS = uSER_PWD_ANS;
85 _uSER_BRI_DATE = uSER_BRI_DATE;
86 _uSER_SEX = uSER_SEX;
87 _uSER_TEL = uSER_TEL;
88 _uSER_EMAIL = uSER_EMAIL;
89 _uSER_INTRODUCE = uSER_INTRODUCE;
90 _uSER_IP = uSER_IP;
91 _uSER_PROXY_IP = uSER_PROXY_IP;
92 _rEMARK = rEMARK;
93 _uSER_BUSINESS_NM = uSER_BUSINESS_NM;
94 _cOURSE_ONLINE = cOURSE_ONLINE;
95 _oTHER_ID = oTHER_ID;
96 _tOP_GROUP_ID = tOP_GROUP_ID;
97 _uSER_FLAG = uSER_FLAG;
98 _lOGIN_TIMES = lOGIN_TIMES;
99 _oTHER_ID_1 = oTHER_ID_1;
100 _oTHER_ID_2 = oTHER_ID_2;
101 _oTHER_ID_3 = oTHER_ID_3;
102 _oTHER_ID_4 = oTHER_ID_4;
103 _oTHER_ID_5 = oTHER_ID_5;
104
105 }
106 #endregion
107
108 #region Public Properties
109
110 public short USER_STATUS
111 {
112 get {return _uSER_STATUS;}
113 set {_uSER_STATUS = value;}
114 }
115
116 public DateTime LAST_LOGIN_TIME
117 {
118 get {return _lAST_LOGIN_TIME;}
119 set {_lAST_LOGIN_TIME = value;}
120 }
121
122 public decimal USER_GROUP_ID
123 {
124 get {return _uSER_GROUP_ID;}
125 set {_uSER_GROUP_ID = value;}
126 }
127
128 public string USER_ID
129 {
130 get {return _uSER_ID;}
131 set {_uSER_ID = value;}
132 }
133
134 public decimal USER_NM
135 {
136 get {return _uSER_NM;}
137 set {_uSER_NM = value;}
138 }
139
140 public short USER_TYPE
141 {
142 get {return _uSER_TYPE;}
143 set {_uSER_TYPE = value;}
144 }
145
146 public string USER_NAME
147 {
148 get {return _uSER_NAME;}
149 set {_uSER_NAME = value;}
150 }
151
152 public string USER_PWD
153 {
154 get {return _uSER_PWD;}
155 set {_uSER_PWD = value;}
156 }
157
158 public string USER_PWD_QUT
159 {
160 get {return _uSER_PWD_QUT;}
161 set {_uSER_PWD_QUT = value;}
162 }
163
164 public string USER_PWD_ANS
165 {
166 get {return _uSER_PWD_ANS;}
167 set {_uSER_PWD_ANS = value;}
168 }
169
170 public DateTime USER_BRI_DATE
171 {
172 get {return _uSER_BRI_DATE;}
173 set {_uSER_BRI_DATE = value;}
174 }
175
176 public short USER_SEX
177 {
178 get {return _uSER_SEX;}
179 set {_uSER_SEX = value;}
180 }
181
182 public string USER_TEL
183 {
184 get {return _uSER_TEL;}
185 set {_uSER_TEL = value;}
186 }
187
188 public string USER_EMAIL
189 {
190 get {return _uSER_EMAIL;}
191 set {_uSER_EMAIL = value;}
192 }
193
194 public string USER_INTRODUCE
195 {
196 get {return _uSER_INTRODUCE;}
197 set {_uSER_INTRODUCE = value;}
198 }
199
200 public string USER_IP
201 {
202 get {return _uSER_IP;}
203 set {_uSER_IP = value;}
204 }
205
206 public string USER_PROXY_IP
207 {
208 get {return _uSER_PROXY_IP;}
209 set {_uSER_PROXY_IP = value;}
210 }
211
212 public string REMARK
213 {
214 get {return _rEMARK;}
215 set {_rEMARK = value;}
216 }
217
218 public decimal USER_BUSINESS_NM
219 {
220 get {return _uSER_BUSINESS_NM;}
221 set {_uSER_BUSINESS_NM = value;}
222 }
223
224 public decimal COURSE_ONLINE
225 {
226 get {return _cOURSE_ONLINE;}
227 set {_cOURSE_ONLINE = value;}
228 }
229
230 public decimal OTHER_ID
231 {
232 get {return _oTHER_ID;}
233 set {_oTHER_ID = value;}
234 }
235
236 public int TOP_GROUP_ID
237 {
238 get {return _tOP_GROUP_ID;}
239 set {_tOP_GROUP_ID = value;}
240 }
241
242 public int USER_FLAG
243 {
244 get {return _uSER_FLAG;}
245 set {_uSER_FLAG = value;}
246 }
247
248 public int LOGIN_TIMES
249 {
250 get {return _lOGIN_TIMES;}
251 set {_lOGIN_TIMES = value;}
252 }
253
254 public string OTHER_ID_1
255 {
256 get {return _oTHER_ID_1;}
257 set {_oTHER_ID_1 = value;}
258 }
259
260 public string OTHER_ID_2
261 {
262 get {return _oTHER_ID_2;}
263 set {_oTHER_ID_2 = value;}
264 }
265
266 public string OTHER_ID_3
267 {
268 get {return _oTHER_ID_3;}
269 set {_oTHER_ID_3 = value;}
270 }
271
272 public string OTHER_ID_4
273 {
274 get {return _oTHER_ID_4;}
275 set {_oTHER_ID_4 = value;}
276 }
277
278 public string OTHER_ID_5
279 {
280 get {return _oTHER_ID_5;}
281 set {_oTHER_ID_5 = value;}
282 }
283
284 public string MobileNo
285 {
286 get { return _mobileno; }
287 set { _mobileno = value; }
288 }
289 #endregion

特向各位高手请教这个Model层的代码是用什么工具生成的,特别是中间红色字体的代码段,本人不解,原来我是用动软生成器生成的,没有中间的那段红色的,谁能告诉我那段红色的代码是做什么的??

我的代码人生的主页 我的代码人生 | 初学一级 | 园豆:7
提问于:2011-04-26 13:38
< >
分享
最佳答案
0

谁能告诉我那段红色的代码是做什么的??

你可以先了解一下构造函数的概念,动软生成的代码只提供了无参构造函数,这里的代码另外提供一个有参的构造函数,Model实例化的时候调用构造函数,无参构造函数,不需要参数,然后给实例的属性赋值;有参构造函数在初始化的时候,直接传递所需的参数。

无参的构造函数,可以这样实例化:

 

public USERSInfo()
{
}

你用的时候是这样:

 

 

USERSInfo user=new USERSInfo();

user.User_Name
="test1";
user.User_IP
="test1";
//……

如果是上面的有参构造函数,可以这样实例化:

USERSInfo user=new USERSInfo("test_name","test_ip",……, "MobileNo");

至于用什么工具生成这个都无所谓,很多代码生成器都可以生成这样的代码,动软调整一下模板也可以生成有参的构造函数。我想你需要了解的面向对象方面的基本知识。
收获园豆:20
上不了岸的鱼 | 老鸟四级 |园豆:4611 | 2011-04-26 15:05
谢谢指教
我的代码人生 | 园豆:7 (初学一级) | 2011-04-26 15:09
其他回答(3)
0

无参构造方法,有参构造方法

dinoy | 园豆:160 (初学一级) | 2011-04-26 13:42
那你知道是什么工具生成的吗? 别告诉我是手写的
支持(0) 反对(0) 我的代码人生 | 园豆:7 (初学一级) | 2011-04-26 13:46
有很多都可以自动生成工具,也可以根据原来自动生成的再手写。codesmith代码生成工具可以自动生成。
支持(0) 反对(0) dinoy | 园豆:160 (初学一级) | 2011-04-26 13:56
0

没必要纠结这个吧?也许人家是自己写的代码生成工具。。。

顾晓北 | 园豆:10241 (专家六级) | 2011-04-26 13:47
0

对滴,这有什么好纠结的,这是个很简单的实体类,红色的部分就是两个最最基本的构造函数用于初始化而已,如果你实在闲的没事干,想研究实体类,不妨看看EF生成的实体类吧,哈哈。

6哒忆夏 | 园豆:594 (小虾三级) | 2011-04-26 15:06
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册