SQL数据库抽像工厂类,方法参数类的定义

  1  /// <summary>
  2     /// 字段模型
  3     /// </summary>
  4     public sealed class ColumnModel
  5     {
  6         public ColumnModel() { }
  7         public ColumnModel(string Column, object DbType)
  8         {
  9             this.ColumnName = Column;
 10             this.ColumnValue = 0;
 11             this.ColumnLen = 0;
 12             this.Directioin = ParameterDirection.Output;
 13             this.DbType = DbType;
 14         }
 15         public ColumnModel(string Column, object Value, int Len, ParameterDirection Dire, object DbType)
 16         {
 17             this.ColumnName = Column;
 18             this.ColumnValue = Value;
 19             this.ColumnLen = Value == null ? 0 : Len;
 20             this.Directioin = Dire;
 21             this.DbType = DbType;
 22         }
 23         public ColumnModel(string Column, object Value, int Len, object DbType)
 24         {
 25             this.ColumnName = Column;
 26             this.ColumnValue = Value;
 27             this.ColumnLen = this.ColumnLen = Value == null ? 0 : Len;
 28             this.Directioin = ParameterDirection.Input;
 29             this.DbType = DbType;
 30         }
 31         public ColumnModel(string Column, object Value, object DbType)
 32         {
 33             this.ColumnName = Column;
 34             this.ColumnValue = Value;
 35             this.ColumnLen = 0;
 36             this.Directioin = ParameterDirection.Input;
 37             this.DbType = DbType;
 38         }
 39         /// <summary>
 40         /// 列名
 41         /// </summary>
 42         public string ColumnName
 43         {
 44             get;
 45             set;
 46         }
 47         /// <summary>
 48         /// 49         /// </summary>
 50         public object ColumnValue
 51         {
 52             get;
 53             set;
 54         }
 55         /// <summary>
 56         /// 长度
 57         /// </summary>
 58         public int ColumnLen
 59         {
 60             get;
 61             set;
 62         }
 63         public ParameterDirection Directioin
 64         {
 65             get;
 66             set;
 67         }
 68         /// <summary>
 69         /// 类型,SqlDbType or OracleType or other
 70         /// </summary>
 71         public object DbType
 72         {
 73             get;
 74             set;
 75         }
 76     }
 77     /// <summary>
 78     /// 表模型
 79     /// </summary>
 80     public sealed class TableModel
 81     {
 82         public TableModel()
 83         {
 84         }
 85         /// <summary>
 86         /// 适用于删除,修改,增加
 87         /// </summary>
 88         /// <param name="Name"></param>
 89         /// <param name="Where"></param>
 90         /// <param name="CmdType"></param>
 91         public TableModel(string Name, WhereColModel[] Where, DataCmdType CmdType)
 92         {
 93             this.TableName = Name;
 94             this.Columns = null;
 95             this.Where = Where;
 96             this.CmdType = CmdType;
 97         }
 98         /// <summary>
 99         /// 适用删除操作
100         /// </summary>
101         /// <param name="Name"></param>
102         /// <param name="Where"></param>
103         public TableModel(string Name, WhereColModel[] Where)
104         {
105             this.TableName = Name;
106             this.Columns = null;
107             this.Where = Where;
108             this.CmdType = DataCmdType.Delete;
109         }
110         /// <summary>
111         /// 适用增删改
112         /// </summary>
113         /// <param name="Name"></param>
114         /// <param name="Columns"></param>
115         /// <param name="Where"></param>
116         /// <param name="CmdType"></param>
117         public TableModel(string Name, ColumnModel[] Columns, WhereColModel[] Where, DataCmdType CmdType)
118         {
119             this.TableName = Name;
120             this.Columns = Columns;
121             this.Where = Where;
122             this.CmdType = CmdType;
123         }
124         /// <summary>
125         /// 表名
126         /// </summary>
127         public string TableName
128         {
129             get;
130             set;
131         }
132         /// <summary>
133         /// 列实体
134         /// </summary>
135         public ColumnModel[] Columns
136         {
137             get;
138             set;
139         }
140         /// <summary>
141         /// 条件
142         /// </summary>
143         public WhereColModel[] Where
144         {
145             get;
146             set;
147         }
148 
149         /// <summary>
150         /// 操作类型
151         /// </summary>
152         public DataCmdType CmdType
153         {
154             get;
155             set;
156         }
157         /// <summary>
158         /// 排序
159         /// </summary>
160         public OrderByType[] OrderBy { get; set; }
161     }
162     public enum DataCmdType { Insert, Update, Delete };
163 
164     /// <summary>
165     /// 排序模型
166     /// </summary>
167     public sealed class OrderByType
168     {
169         /// <summary>
170         /// 排序列
171         /// </summary>
172         public string Cols
173         {
174             get;
175             set;
176         }
177         public OrderBy Orderby
178         {
179             get;
180             set;
181         }
182     }
183     public enum OrderBy { Asc, Desc };
184 
185     /// <summary>
186     /// 调用存储过程模型
187     /// </summary>
188     public sealed class SqlProModel
189     {
190         /// <summary>
191         /// 存储过程名称
192         /// </summary>
193         public string ProName { get; set; }
194         /// <summary>
195         /// 存储过程参数
196         /// </summary>
197         public ColumnModel[] DataParamer { get; set; }
198     }
199 
200     /// <summary>
201     /// 查询条件模型
202     /// </summary>
203     public sealed class WhereColModel
204     {
205         /// <summary>
206         /// 列名
207         /// </summary>
208         public string ColumnName
209         {
210             get;
211             set;
212         }
213         /// <summary>
214         ///215         /// </summary>
216         public object ColumnValue
217         {
218             get;
219             set;
220         }
221         /// <summary>
222         /// 是否采用单引号
223         /// </summary>
224         public bool leftQuotes { get; set; }
225         /// <summary>
226         /// 是否采用单引号
227         /// </summary>
228         public bool Quotes { get; set; }
229         /// <summary>
230         /// and 或者 or
231         /// </summary>
232         public bool AndOr { get; set; }
233         /// <summary>
234         /// 比较方式
235         /// </summary>
236         public WhereCom Com { get; set; }
237         /// <summary>
238         /// 是否开始括号
239         /// </summary>
240         public bool BeginBrackets { get; set; }
241         /// <summary>
242         /// 是否结束括号
243         /// </summary>
244         public bool EndBrackets { get; set; }
245     }
246     public enum WhereCom
247     {
248         /// <summary>
249         /// =
250         /// </summary>
251         [Description("=")]
252         Equal,
253         /// <summary>
254         /// !=
255         /// </summary>
256         [Description("!=")]
257         NotEqual,
258         /// <summary>
259         /// <
260         /// </summary>
261         [Description("<")]
262         Less,
263         /// <summary>
264         /// >
265         /// </summary>
266         [Description(">")]
267         Greater,
268         /// <summary>
269         /// >=
270         /// </summary>
271         [Description(">=")]
272         GreaterEqual,
273         /// <summary>
274         /// <=
275         /// </summary>
276         [Description("<=")]
277         LessEqual,
278         /// <summary>
279         /// like %str%
280         /// </summary>
281         [Description("like %str%")]
282         Like,
283         /// <summary>
284         /// like %str
285         /// </summary>
286         [Description("like %str")]
287         LeftLike,
288         /// <summary>
289         /// like str%
290         /// </summary>
291         [Description("like str%")]
292         RightLike,
293          /// <summary>
294         /// in
295         /// </summary>
296         [Description("in(str)")]
297         IN,
298         /// <summary>
299         /// in
300         /// </summary>
301         [Description("not in(str)")]
302         NOTIN
303     };
304     /// <summary>
305     /// 条件符号
306     /// </summary>
307     public struct ComSymbol
308     {
309         public Hashtable Symbol()
310         {
311             Hashtable Tb = new Hashtable();
312             Tb.Add("Equal", "{0}{1}{2}={3}{4}{5}");
313             Tb.Add("NotEqual", "{0}{1}{2}!={3}{4}{5}");
314             Tb.Add("Less", "{0}{1}{2}<{3}{4}{5}");
315             Tb.Add("Greater", "{0}{1}{2}>{3}{4}{5}");
316             Tb.Add("GreaterEqual", "{0}{1}{2}>={3}{4}{5}");
317             Tb.Add("LessEqual", "{0}{1}{2}<={3}{4}{5}");
318             Tb.Add("Like", "{0}{1}{2} like %{3}{4}{5}%");
319             Tb.Add("LeftLike", "{0}{1}{2} like %{3}{4}{5}");
320             Tb.Add("RightLike", "{0}{1}{2} like {3}{4}{5}%");
321             Tb.Add("IN", "{0}{1}{2} in({3}{4}{5})");
322             Tb.Add("NOTIN", "{0}{1}{2} not in({3}{4}{5})");
323             return Tb;
324         }
325     }
326     /// <summary>
327     /// 数据查询模型
328     /// </summary>
329     public sealed class SelectModel
330     {
331         /// <summary>
332         /// 表名
333         /// </summary>
334         public string TableName
335         {
336             get;
337             set;
338         }
339         /// <summary>
340         /// 要返回的列
341         /// </summary>
342         public string Cols
343         {
344             get;
345             set;
346         }
347         /// <summary>
348         /// 条件
349         /// </summary>
350         public WhereColModel[] Where
351         {
352             get;
353             set;
354         }
355         public OrderByType[] OrderBy { get; set; }
356     }
357 
358     public sealed class UrlCommand
359     {
360         public string CmdDist
361         {
362             get;
363             set;
364         }
365         public string CmdStr
366         {
367             get;
368             set;
369         }
370     }

 

posted on 2013-03-22 22:47  FLASHFYZ  阅读(227)  评论(0编辑  收藏  举报

导航