Mercurial > pub > bltoolkit
comparison Demo/WinForms/BusinessLogic/ManagerBase.cs @ 0:f990fcb411a9
Копия текущей версии из github
author | cin |
---|---|
date | Thu, 27 Mar 2014 21:46:09 +0400 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:f990fcb411a9 |
---|---|
1 using System; | |
2 | |
3 using BLToolkit.DataAccess; | |
4 using BLToolkit.EditableObjects; | |
5 | |
6 using BLToolkit.Demo.ObjectModel; | |
7 using BLToolkit.Demo.BusinessLogic.DataAccess; | |
8 | |
9 namespace BLToolkit.Demo.BusinessLogic | |
10 { | |
11 public abstract class ManagerBase<T,A> | |
12 where T : BizEntity | |
13 where A : AccessorBase<T,A> | |
14 { | |
15 #region Insert, Update, Delete | |
16 | |
17 public void Insert(T obj) | |
18 { | |
19 obj.Validate(); | |
20 | |
21 obj.ID = Accessor.Insert(obj); | |
22 | |
23 obj.AcceptChanges(); | |
24 } | |
25 | |
26 public void Update(T obj) | |
27 { | |
28 obj.Validate(); | |
29 | |
30 Query.Update(obj); | |
31 | |
32 obj.AcceptChanges(); | |
33 } | |
34 | |
35 public void Delete(T obj) | |
36 { | |
37 Query.Delete(obj); | |
38 } | |
39 | |
40 public void Delete(int id) | |
41 { | |
42 Query.DeleteByKey(id); | |
43 } | |
44 | |
45 #endregion | |
46 | |
47 #region Select | |
48 | |
49 public EditableList<T> SelectAll() | |
50 { | |
51 EditableList<T> list = new EditableList<T>(); | |
52 | |
53 return Query.SelectAll(list); | |
54 } | |
55 | |
56 #endregion | |
57 | |
58 #region Protected Members | |
59 | |
60 protected virtual A Accessor | |
61 { | |
62 get { return AccessorBase<T,A>.CreateInstance(); } | |
63 } | |
64 | |
65 private SqlQuery<T> _query; | |
66 protected virtual SqlQuery<T> Query | |
67 { | |
68 get | |
69 { | |
70 if (null == _query) | |
71 _query = new SqlQuery<T>(); | |
72 | |
73 return _query; | |
74 } | |
75 } | |
76 | |
77 #endregion | |
78 } | |
79 } |