实体和实体的集合
这几天在研究实体和实体的集合的写法,基本上完成了数据绑定,但是还是没有完全完成
上面是实体的集合,下面是实体的写法
1
using System;
2
using System.Collections;
3
using System.ComponentModel;
4![](/Images/OutliningIndicators/None.gif)
5
namespace Entity
6
{
7
/// <summary>
8
/// 类OrderInfo的集合
9
/// </summary>
10
public class OrderInfoCollection : CollectionBase,IBindingList
11
{
12
#region CollectionBase实现
13![](/Images/OutliningIndicators/InBlock.gif)
14
public OrderInfoCollection()
15
{
16
}
17![](/Images/OutliningIndicators/InBlock.gif)
18
public OrderInfoCollection(OrderInfo[] value)
19
{
20
this.AddRange(value);
21
}
22
23
public OrderInfo this[int index]
24
{
25
get{return ((OrderInfo)(this.List[index]));}
26
set{List[index] = value;}
27
}
28![](/Images/OutliningIndicators/InBlock.gif)
29
public int Add(OrderInfo value)
30
{
31
return this.List.Add(value);
32
}
33![](/Images/OutliningIndicators/InBlock.gif)
34
public OrderInfo AddNew()
35
{
36
return (OrderInfo)((IBindingList)this).AddNew();
37
}
38![](/Images/OutliningIndicators/InBlock.gif)
39
object IBindingList.AddNew()
40
{
41
OrderInfo c = new OrderInfo();
42
List.Add(c);
43
return c;
44
}
45![](/Images/OutliningIndicators/InBlock.gif)
46
public void AddRange(OrderInfo[] value)
47
{
48
for (int i = 0; (i < value.Length); i = (i + 1))
49
{
50
this.Add(value[i]);
51
}
52
}
53![](/Images/OutliningIndicators/InBlock.gif)
54
public void AddRange(OrderInfoCollection value)
55
{
56
for (int i = 0; (i < value.Count); i = (i + 1))
57
{
58
this.Add((OrderInfo)value.List[i]);
59
}
60
}
61![](/Images/OutliningIndicators/InBlock.gif)
62
public bool Contains(OrderInfo value)
63
{
64
return this.List.Contains(value);
65
}
66![](/Images/OutliningIndicators/InBlock.gif)
67
public void CopyTo(OrderInfo[] array, int index)
68
{
69
this.List.CopyTo(array, index);
70
}
71![](/Images/OutliningIndicators/InBlock.gif)
72
public int IndexOf(OrderInfo value)
73
{
74
return this.List.IndexOf(value);
75
}
76![](/Images/OutliningIndicators/InBlock.gif)
77
public void Insert(int index, OrderInfo value)
78
{
79
List.Insert(index, value);
80
}
81![](/Images/OutliningIndicators/InBlock.gif)
82
public void Remove(OrderInfo value)
83
{
84
List.Remove(value);
85
}
86![](/Images/OutliningIndicators/InBlock.gif)
87
public new OrderInfoCollectionEnumerator GetEnumerator()
88
{
89
return new OrderInfoCollectionEnumerator(this);
90
}
91![](/Images/OutliningIndicators/InBlock.gif)
92
#endregion
93![](/Images/OutliningIndicators/InBlock.gif)
94![](/Images/OutliningIndicators/InBlock.gif)
95
#region OrderInfoCollectionEnumerator 实现
96![](/Images/OutliningIndicators/InBlock.gif)
97
public class OrderInfoCollectionEnumerator : IEnumerator
98
{
99
private IEnumerator _enumerator;
100
private IEnumerable _temp;
101
102
public OrderInfoCollectionEnumerator(OrderInfoCollection mappings)
103
{
104
_temp = ((IEnumerable)(mappings));
105
_enumerator = _temp.GetEnumerator();
106
}
107
108
public OrderInfo Current
109
{
110
get {return ((OrderInfo)(_enumerator.Current));}
111
}
112
113
object IEnumerator.Current
114
{
115
get {return _enumerator.Current;}
116
}
117
118
public bool MoveNext()
119
{
120
return _enumerator.MoveNext();
121
}
122
123
bool IEnumerator.MoveNext()
124
{
125
return _enumerator.MoveNext();
126
}
127
128
public void Reset()
129
{
130
_enumerator.Reset();
131
}
132
133
void IEnumerator.Reset()
134
{
135
_enumerator.Reset();
136
}
137
}
138
#endregion
139![](/Images/OutliningIndicators/InBlock.gif)
140![](/Images/OutliningIndicators/InBlock.gif)
141
#region IBindingList 成员
142![](/Images/OutliningIndicators/InBlock.gif)
143
private ListChangedEventArgs resetEvent = new ListChangedEventArgs(ListChangedType.Reset, -1);
144
private ListChangedEventHandler onListChanged;
145![](/Images/OutliningIndicators/InBlock.gif)
146
public bool AllowEdit
147
{
148
get {return true;}
149
}
150![](/Images/OutliningIndicators/InBlock.gif)
151
public bool AllowNew
152
{
153
get {return true;}
154
}
155![](/Images/OutliningIndicators/InBlock.gif)
156
public bool AllowRemove
157
{
158
get {return true;}
159
}
160![](/Images/OutliningIndicators/InBlock.gif)
161
public bool SupportsChangeNotification
162
{
163
get {return true;}
164
}
165![](/Images/OutliningIndicators/InBlock.gif)
166
public bool SupportsSearching
167
{
168
get {return false;}
169
}
170![](/Images/OutliningIndicators/InBlock.gif)
171
public bool SupportsSorting
172
{
173
get {return false;}
174
}
175![](/Images/OutliningIndicators/InBlock.gif)
176
public void AddIndex(PropertyDescriptor property)
177
{
178
throw new NotSupportedException();
179
}
180
public void ApplySort(PropertyDescriptor property, System.ComponentModel.ListSortDirection direction)
181
{
182
throw new NotSupportedException();
183
}
184
public PropertyDescriptor SortProperty
185
{
186
get{throw new NotSupportedException();
187
//return null;
188
}
189
}
190
public int Find(PropertyDescriptor property, object key)
191
{
192
throw new NotSupportedException();
193
//return 0;
194
}
195
public void RemoveSort()
196
{
197
throw new NotSupportedException();
198
}
199
public void RemoveIndex(PropertyDescriptor property)
200
{
201
throw new NotSupportedException();
202
}
203
public bool IsSorted
204
{
205
get { throw new NotSupportedException();
206
//return false;
207
}
208
}
209
public System.ComponentModel.ListSortDirection SortDirection
210
{
211
get{throw new NotSupportedException();
212
//return new System.ComponentModel.ListSortDirection ();
213
}
214
}
215
public event ListChangedEventHandler ListChanged
216
{
217
add{onListChanged += value;}
218
remove{onListChanged -= value;}
219
}
220![](/Images/OutliningIndicators/InBlock.gif)
221
protected virtual void OnListChanged(ListChangedEventArgs ev)
222
{
223
if (onListChanged != null)
224
{
225
onListChanged(this, ev);
226
}
227
}
228
protected override void OnClearComplete()
229
{
230
OnListChanged(resetEvent);
231
}
232
private void RemoveChild(Object source, OrderInfo.OrderInfoEventArgs e)
233
{
234
List.Remove(source);
235
}
236
protected override void OnInsertComplete(int index, object value)
237
{
238
((OrderInfo)(value)).RemoveMe += new OrderInfo.OrderInfoEventHandler(RemoveChild);
239
OnListChanged(new ListChangedEventArgs(ListChangedType.ItemAdded, index));
240
}
241
protected override void OnRemoveComplete(int index, object value)
242
{
243
OnListChanged(new ListChangedEventArgs(ListChangedType.ItemDeleted, index));
244
}
245
protected override void OnSetComplete(int index, object oldValue, object newValue)
246
{
247
if (oldValue != newValue)
248
{
249
OnListChanged(new ListChangedEventArgs(ListChangedType.ItemAdded, index));
250
}
251
}
252![](/Images/OutliningIndicators/InBlock.gif)
253
#endregion
254
}
255
}
![](/Images/OutliningIndicators/None.gif)
2
![](/Images/OutliningIndicators/None.gif)
3
![](/Images/OutliningIndicators/None.gif)
4
![](/Images/OutliningIndicators/None.gif)
5
![](/Images/OutliningIndicators/None.gif)
6
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
7
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
8
![](/Images/OutliningIndicators/InBlock.gif)
9
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
10
![](/Images/OutliningIndicators/InBlock.gif)
11
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
12
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
13
![](/Images/OutliningIndicators/InBlock.gif)
14
![](/Images/OutliningIndicators/InBlock.gif)
15
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
16
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
17
![](/Images/OutliningIndicators/InBlock.gif)
18
![](/Images/OutliningIndicators/InBlock.gif)
19
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
20
![](/Images/OutliningIndicators/InBlock.gif)
21
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
22
![](/Images/OutliningIndicators/InBlock.gif)
23
![](/Images/OutliningIndicators/InBlock.gif)
24
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
25
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
26
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
27
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
28
![](/Images/OutliningIndicators/InBlock.gif)
29
![](/Images/OutliningIndicators/InBlock.gif)
30
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
31
![](/Images/OutliningIndicators/InBlock.gif)
32
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
33
![](/Images/OutliningIndicators/InBlock.gif)
34
![](/Images/OutliningIndicators/InBlock.gif)
35
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
36
![](/Images/OutliningIndicators/InBlock.gif)
37
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
38
![](/Images/OutliningIndicators/InBlock.gif)
39
![](/Images/OutliningIndicators/InBlock.gif)
40
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
41
![](/Images/OutliningIndicators/InBlock.gif)
42
![](/Images/OutliningIndicators/InBlock.gif)
43
![](/Images/OutliningIndicators/InBlock.gif)
44
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
45
![](/Images/OutliningIndicators/InBlock.gif)
46
![](/Images/OutliningIndicators/InBlock.gif)
47
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
48
![](/Images/OutliningIndicators/InBlock.gif)
49
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
50
![](/Images/OutliningIndicators/InBlock.gif)
51
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
52
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
53
![](/Images/OutliningIndicators/InBlock.gif)
54
![](/Images/OutliningIndicators/InBlock.gif)
55
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
56
![](/Images/OutliningIndicators/InBlock.gif)
57
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
58
![](/Images/OutliningIndicators/InBlock.gif)
59
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
60
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
61
![](/Images/OutliningIndicators/InBlock.gif)
62
![](/Images/OutliningIndicators/InBlock.gif)
63
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
64
![](/Images/OutliningIndicators/InBlock.gif)
65
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
66
![](/Images/OutliningIndicators/InBlock.gif)
67
![](/Images/OutliningIndicators/InBlock.gif)
68
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
69
![](/Images/OutliningIndicators/InBlock.gif)
70
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
71
![](/Images/OutliningIndicators/InBlock.gif)
72
![](/Images/OutliningIndicators/InBlock.gif)
73
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
74
![](/Images/OutliningIndicators/InBlock.gif)
75
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
76
![](/Images/OutliningIndicators/InBlock.gif)
77
![](/Images/OutliningIndicators/InBlock.gif)
78
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
79
![](/Images/OutliningIndicators/InBlock.gif)
80
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
81
![](/Images/OutliningIndicators/InBlock.gif)
82
![](/Images/OutliningIndicators/InBlock.gif)
83
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
84
![](/Images/OutliningIndicators/InBlock.gif)
85
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
86
![](/Images/OutliningIndicators/InBlock.gif)
87
![](/Images/OutliningIndicators/InBlock.gif)
88
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
89
![](/Images/OutliningIndicators/InBlock.gif)
90
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
91
![](/Images/OutliningIndicators/InBlock.gif)
92
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
93
![](/Images/OutliningIndicators/InBlock.gif)
94
![](/Images/OutliningIndicators/InBlock.gif)
95
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
96
![](/Images/OutliningIndicators/InBlock.gif)
97
![](/Images/OutliningIndicators/InBlock.gif)
98
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
99
![](/Images/OutliningIndicators/InBlock.gif)
100
![](/Images/OutliningIndicators/InBlock.gif)
101
![](/Images/OutliningIndicators/InBlock.gif)
102
![](/Images/OutliningIndicators/InBlock.gif)
103
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
104
![](/Images/OutliningIndicators/InBlock.gif)
105
![](/Images/OutliningIndicators/InBlock.gif)
106
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
107
![](/Images/OutliningIndicators/InBlock.gif)
108
![](/Images/OutliningIndicators/InBlock.gif)
109
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
110
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
111
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
112
![](/Images/OutliningIndicators/InBlock.gif)
113
![](/Images/OutliningIndicators/InBlock.gif)
114
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
115
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
116
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
117
![](/Images/OutliningIndicators/InBlock.gif)
118
![](/Images/OutliningIndicators/InBlock.gif)
119
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
120
![](/Images/OutliningIndicators/InBlock.gif)
121
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
122
![](/Images/OutliningIndicators/InBlock.gif)
123
![](/Images/OutliningIndicators/InBlock.gif)
124
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
125
![](/Images/OutliningIndicators/InBlock.gif)
126
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
127
![](/Images/OutliningIndicators/InBlock.gif)
128
![](/Images/OutliningIndicators/InBlock.gif)
129
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
130
![](/Images/OutliningIndicators/InBlock.gif)
131
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
132
![](/Images/OutliningIndicators/InBlock.gif)
133
![](/Images/OutliningIndicators/InBlock.gif)
134
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
135
![](/Images/OutliningIndicators/InBlock.gif)
136
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
137
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
138
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
139
![](/Images/OutliningIndicators/InBlock.gif)
140
![](/Images/OutliningIndicators/InBlock.gif)
141
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
142
![](/Images/OutliningIndicators/InBlock.gif)
143
![](/Images/OutliningIndicators/InBlock.gif)
144
![](/Images/OutliningIndicators/InBlock.gif)
145
![](/Images/OutliningIndicators/InBlock.gif)
146
![](/Images/OutliningIndicators/InBlock.gif)
147
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
148
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
149
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
150
![](/Images/OutliningIndicators/InBlock.gif)
151
![](/Images/OutliningIndicators/InBlock.gif)
152
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
153
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
154
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
155
![](/Images/OutliningIndicators/InBlock.gif)
156
![](/Images/OutliningIndicators/InBlock.gif)
157
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
158
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
159
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
160
![](/Images/OutliningIndicators/InBlock.gif)
161
![](/Images/OutliningIndicators/InBlock.gif)
162
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
163
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
164
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
165
![](/Images/OutliningIndicators/InBlock.gif)
166
![](/Images/OutliningIndicators/InBlock.gif)
167
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
168
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
169
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
170
![](/Images/OutliningIndicators/InBlock.gif)
171
![](/Images/OutliningIndicators/InBlock.gif)
172
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
173
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
174
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
175
![](/Images/OutliningIndicators/InBlock.gif)
176
![](/Images/OutliningIndicators/InBlock.gif)
177
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
178
![](/Images/OutliningIndicators/InBlock.gif)
179
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
180
![](/Images/OutliningIndicators/InBlock.gif)
181
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
182
![](/Images/OutliningIndicators/InBlock.gif)
183
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
184
![](/Images/OutliningIndicators/InBlock.gif)
185
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
186
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
187
![](/Images/OutliningIndicators/InBlock.gif)
188
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
189
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
190
![](/Images/OutliningIndicators/InBlock.gif)
191
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
192
![](/Images/OutliningIndicators/InBlock.gif)
193
![](/Images/OutliningIndicators/InBlock.gif)
194
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
195
![](/Images/OutliningIndicators/InBlock.gif)
196
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
197
![](/Images/OutliningIndicators/InBlock.gif)
198
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
199
![](/Images/OutliningIndicators/InBlock.gif)
200
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
201
![](/Images/OutliningIndicators/InBlock.gif)
202
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
203
![](/Images/OutliningIndicators/InBlock.gif)
204
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
205
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
206
![](/Images/OutliningIndicators/InBlock.gif)
207
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
208
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
209
![](/Images/OutliningIndicators/InBlock.gif)
210
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
211
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
212
![](/Images/OutliningIndicators/InBlock.gif)
213
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
214
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
215
![](/Images/OutliningIndicators/InBlock.gif)
216
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
217
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
218
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
219
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
220
![](/Images/OutliningIndicators/InBlock.gif)
221
![](/Images/OutliningIndicators/InBlock.gif)
222
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
223
![](/Images/OutliningIndicators/InBlock.gif)
224
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
225
![](/Images/OutliningIndicators/InBlock.gif)
226
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
227
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
228
![](/Images/OutliningIndicators/InBlock.gif)
229
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
230
![](/Images/OutliningIndicators/InBlock.gif)
231
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
232
![](/Images/OutliningIndicators/InBlock.gif)
233
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
234
![](/Images/OutliningIndicators/InBlock.gif)
235
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
236
![](/Images/OutliningIndicators/InBlock.gif)
237
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
238
![](/Images/OutliningIndicators/InBlock.gif)
239
![](/Images/OutliningIndicators/InBlock.gif)
240
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
241
![](/Images/OutliningIndicators/InBlock.gif)
242
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
243
![](/Images/OutliningIndicators/InBlock.gif)
244
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
245
![](/Images/OutliningIndicators/InBlock.gif)
246
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
247
![](/Images/OutliningIndicators/InBlock.gif)
248
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
249
![](/Images/OutliningIndicators/InBlock.gif)
250
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
251
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
252
![](/Images/OutliningIndicators/InBlock.gif)
253
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
254
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
255
![](/Images/OutliningIndicators/ExpandedBlockEnd.gif)
上面是实体的集合,下面是实体的写法
1
using System;
2
using System.Data;
3
using System.Collections;
4
using System.ComponentModel;
5![](/Images/OutliningIndicators/None.gif)
6
namespace Entity
7
{
8
/// <summary>
9
/// Order的描述
10
/// </summary>
11
public class OrderInfo : IEditableObject,IDataErrorInfo
12
{
13![](/Images/OutliningIndicators/InBlock.gif)
14
#region 实体 结构体
15
/// <summary>
16
/// 类OrderInfo的实体结构体
17
/// </summary>
18
struct OrderInfoData
19
{
20
internal string _id;
21
internal string _name;
22
}
23![](/Images/OutliningIndicators/InBlock.gif)
24
#endregion
25![](/Images/OutliningIndicators/InBlock.gif)
26![](/Images/OutliningIndicators/InBlock.gif)
27
#region 私有变量
28![](/Images/OutliningIndicators/InBlock.gif)
29
private OrderInfoData custData; //类实体的值
30
private OrderInfoData backupData; //类实体的备份值(用于CancelEdit的时候的恢复)
31
private bool mEditing = false; //是否处于编辑状态
32
private bool mIsNew = true; //是否是新建状态
33![](/Images/OutliningIndicators/InBlock.gif)
34
#endregion
35![](/Images/OutliningIndicators/InBlock.gif)
36![](/Images/OutliningIndicators/InBlock.gif)
37
#region 构造函数
38![](/Images/OutliningIndicators/InBlock.gif)
39
/// <summary>
40
/// 默认构造函数
41
/// </summary>
42
public OrderInfo():base()
43
{
44
this.custData = new OrderInfoData();
45
this.custData._id = "";
46
this.custData._name = "";
47
}
48![](/Images/OutliningIndicators/InBlock.gif)
49![](/Images/OutliningIndicators/InBlock.gif)
50
/// <summary>
51
/// 构造函数,所有公开属性赋值
52
/// </summary>
53
/// <param name="m_id">属性ID的描述</param>
54
/// <param name="m_name">属性Name的描述</param>
55
public OrderInfo(string m_id,string m_name)
56
{
57
this.custData = new OrderInfoData();
58
this.custData._id = m_id;
59
this.custData._name = m_name;
60
}
61![](/Images/OutliningIndicators/InBlock.gif)
62
#endregion
63![](/Images/OutliningIndicators/InBlock.gif)
64![](/Images/OutliningIndicators/InBlock.gif)
65
#region 实体属性
66![](/Images/OutliningIndicators/InBlock.gif)
67
/// <summary>
68
/// 属性ID的描述
69
/// </summary>
70
public string ID
71
{
72
get{return this.custData._id;}
73
set{this.custData._id = value;}
74
}
75![](/Images/OutliningIndicators/InBlock.gif)
76
/// <summary>
77
/// 属性Name的描述
78
/// </summary>
79
public string Name
80
{
81
get{return this.custData._name;}
82
set{this.custData._name = value;}
83
}
84![](/Images/OutliningIndicators/InBlock.gif)
85![](/Images/OutliningIndicators/InBlock.gif)
86
#endregion
87![](/Images/OutliningIndicators/InBlock.gif)
88![](/Images/OutliningIndicators/InBlock.gif)
89
#region IEditableObject 成员
90![](/Images/OutliningIndicators/InBlock.gif)
91
public void EndEdit()
92
{
93
if (mEditing)
94
{
95
mEditing = false;
96
mIsNew = false;
97
}
98
}
99![](/Images/OutliningIndicators/InBlock.gif)
100
internal class OrderInfoEventArgs : EventArgs
101
{
102
// 定义事件成员,用于提供有关事件的信息
103
}
104
internal delegate void OrderInfoEventHandler(Object source, OrderInfoEventArgs e);
105
internal event OrderInfoEventHandler RemoveMe;
106
public void CancelEdit()
107
{
108
if (mEditing)
109
{
110
mEditing = false;
111
this.custData = backupData;
112
if(mIsNew)
113
{
114
mIsNew = false;
115
RemoveMe(this, new OrderInfoEventArgs());
116
}
117
}
118
}
119![](/Images/OutliningIndicators/InBlock.gif)
120
public void BeginEdit()
121
{
122
if (!mEditing)
123
{
124
mEditing = true;
125
this.backupData = custData;
126
}
127
}
128![](/Images/OutliningIndicators/InBlock.gif)
129
#endregion
130![](/Images/OutliningIndicators/InBlock.gif)
131![](/Images/OutliningIndicators/InBlock.gif)
132
#region IDataErrorInfo 成员
133![](/Images/OutliningIndicators/InBlock.gif)
134
public string Error
135
{
136
get{return "";}
137
}
138![](/Images/OutliningIndicators/InBlock.gif)
139
public string this[string strErrorName]
140
{
141
get{return "";}
142
}
143![](/Images/OutliningIndicators/InBlock.gif)
144
#endregion
145
}
146
}
![](/Images/OutliningIndicators/None.gif)
2
![](/Images/OutliningIndicators/None.gif)
3
![](/Images/OutliningIndicators/None.gif)
4
![](/Images/OutliningIndicators/None.gif)
5
![](/Images/OutliningIndicators/None.gif)
6
![](/Images/OutliningIndicators/None.gif)
7
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
8
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
9
![](/Images/OutliningIndicators/InBlock.gif)
10
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
11
![](/Images/OutliningIndicators/InBlock.gif)
12
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
13
![](/Images/OutliningIndicators/InBlock.gif)
14
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
15
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
16
![](/Images/OutliningIndicators/InBlock.gif)
17
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
18
![](/Images/OutliningIndicators/InBlock.gif)
19
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
20
![](/Images/OutliningIndicators/InBlock.gif)
21
![](/Images/OutliningIndicators/InBlock.gif)
22
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
23
![](/Images/OutliningIndicators/InBlock.gif)
24
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
25
![](/Images/OutliningIndicators/InBlock.gif)
26
![](/Images/OutliningIndicators/InBlock.gif)
27
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
28
![](/Images/OutliningIndicators/InBlock.gif)
29
![](/Images/OutliningIndicators/InBlock.gif)
30
![](/Images/OutliningIndicators/InBlock.gif)
31
![](/Images/OutliningIndicators/InBlock.gif)
32
![](/Images/OutliningIndicators/InBlock.gif)
33
![](/Images/OutliningIndicators/InBlock.gif)
34
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
35
![](/Images/OutliningIndicators/InBlock.gif)
36
![](/Images/OutliningIndicators/InBlock.gif)
37
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
38
![](/Images/OutliningIndicators/InBlock.gif)
39
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
40
![](/Images/OutliningIndicators/InBlock.gif)
41
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
42
![](/Images/OutliningIndicators/InBlock.gif)
43
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
44
![](/Images/OutliningIndicators/InBlock.gif)
45
![](/Images/OutliningIndicators/InBlock.gif)
46
![](/Images/OutliningIndicators/InBlock.gif)
47
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
48
![](/Images/OutliningIndicators/InBlock.gif)
49
![](/Images/OutliningIndicators/InBlock.gif)
50
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
51
![](/Images/OutliningIndicators/InBlock.gif)
52
![](/Images/OutliningIndicators/InBlock.gif)
53
![](/Images/OutliningIndicators/InBlock.gif)
54
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
55
![](/Images/OutliningIndicators/InBlock.gif)
56
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
57
![](/Images/OutliningIndicators/InBlock.gif)
58
![](/Images/OutliningIndicators/InBlock.gif)
59
![](/Images/OutliningIndicators/InBlock.gif)
60
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
61
![](/Images/OutliningIndicators/InBlock.gif)
62
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
63
![](/Images/OutliningIndicators/InBlock.gif)
64
![](/Images/OutliningIndicators/InBlock.gif)
65
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
66
![](/Images/OutliningIndicators/InBlock.gif)
67
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
68
![](/Images/OutliningIndicators/InBlock.gif)
69
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
70
![](/Images/OutliningIndicators/InBlock.gif)
71
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
72
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
73
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
74
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
75
![](/Images/OutliningIndicators/InBlock.gif)
76
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
77
![](/Images/OutliningIndicators/InBlock.gif)
78
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
79
![](/Images/OutliningIndicators/InBlock.gif)
80
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
81
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
82
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
83
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
84
![](/Images/OutliningIndicators/InBlock.gif)
85
![](/Images/OutliningIndicators/InBlock.gif)
86
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
87
![](/Images/OutliningIndicators/InBlock.gif)
88
![](/Images/OutliningIndicators/InBlock.gif)
89
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
90
![](/Images/OutliningIndicators/InBlock.gif)
91
![](/Images/OutliningIndicators/InBlock.gif)
92
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
93
![](/Images/OutliningIndicators/InBlock.gif)
94
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
95
![](/Images/OutliningIndicators/InBlock.gif)
96
![](/Images/OutliningIndicators/InBlock.gif)
97
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
98
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
99
![](/Images/OutliningIndicators/InBlock.gif)
100
![](/Images/OutliningIndicators/InBlock.gif)
101
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
102
![](/Images/OutliningIndicators/InBlock.gif)
103
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
104
![](/Images/OutliningIndicators/InBlock.gif)
105
![](/Images/OutliningIndicators/InBlock.gif)
106
![](/Images/OutliningIndicators/InBlock.gif)
107
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
108
![](/Images/OutliningIndicators/InBlock.gif)
109
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
110
![](/Images/OutliningIndicators/InBlock.gif)
111
![](/Images/OutliningIndicators/InBlock.gif)
112
![](/Images/OutliningIndicators/InBlock.gif)
113
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
114
![](/Images/OutliningIndicators/InBlock.gif)
115
![](/Images/OutliningIndicators/InBlock.gif)
116
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
117
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
118
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
119
![](/Images/OutliningIndicators/InBlock.gif)
120
![](/Images/OutliningIndicators/InBlock.gif)
121
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
122
![](/Images/OutliningIndicators/InBlock.gif)
123
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
124
![](/Images/OutliningIndicators/InBlock.gif)
125
![](/Images/OutliningIndicators/InBlock.gif)
126
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
127
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
128
![](/Images/OutliningIndicators/InBlock.gif)
129
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
130
![](/Images/OutliningIndicators/InBlock.gif)
131
![](/Images/OutliningIndicators/InBlock.gif)
132
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
133
![](/Images/OutliningIndicators/InBlock.gif)
134
![](/Images/OutliningIndicators/InBlock.gif)
135
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
136
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
137
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
138
![](/Images/OutliningIndicators/InBlock.gif)
139
![](/Images/OutliningIndicators/InBlock.gif)
140
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
141
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
142
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
143
![](/Images/OutliningIndicators/InBlock.gif)
144
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
145
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
146
![](/Images/OutliningIndicators/ExpandedBlockEnd.gif)