IBaseDataLaye.cs 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. using System.Data;
  5. namespace LYFZ.StandardInterface
  6. {
  7. /// <summary>
  8. /// 数据层基础接口
  9. /// </summary>
  10. public interface IBaseDataLaye
  11. {
  12. #region 属性
  13. /// <summary>
  14. /// 数据表模型对象
  15. /// </summary>
  16. object ObjModel { get; }
  17. /// <summary>
  18. /// 数据表名
  19. /// </summary>
  20. string TableName { get; set; }
  21. /// <summary>
  22. /// 数据表字段名字符串,字段名以“,”号分隔
  23. /// </summary>
  24. string TableFieldNameString { get; set; }
  25. /// <summary>
  26. /// 数据表字段名数组
  27. /// </summary>
  28. string[] TableFieldNames { get; }
  29. #endregion
  30. #region 检查记录
  31. /// <summary>
  32. /// 是否存在该记录
  33. /// </summary>
  34. bool Exists(int ID);
  35. /// <summary>
  36. /// 根据筛选条件判断是否存在该记录
  37. /// </summary>
  38. /// <param name="filterFieldName">筛选字段名</param>
  39. /// <param name="filterValue">筛选值</param>
  40. /// <returns></returns>
  41. bool Exists(string filterFieldName, object filterValue);
  42. /// <summary>
  43. /// 判断是否存某个字段
  44. /// </summary>
  45. /// <param name="columnName">列名称</param>
  46. /// <returns>是否存在</returns>
  47. bool ColumnExists(string columnName);
  48. #endregion
  49. #region 公共方法
  50. /// <summary>
  51. /// 获取最大ID()
  52. /// </summary>
  53. /// <returns></returns>
  54. int GetMaxID();
  55. /// <summary>
  56. /// 获取某字段最大值(获取字段必须为数字类型)
  57. /// </summary>
  58. /// <param name="FieldName">字段名</param>
  59. /// <returns></returns>
  60. int GetMaxID(string FieldName);
  61. #endregion
  62. #region 增加数据
  63. /// <summary>
  64. /// 增加一条数据
  65. /// </summary>
  66. /// <param name="model">Model对象</param>
  67. /// <param name="overlookFieldList">忽略字段名列表 字段名之间用“,”号分隔</param>
  68. /// <returns></returns>
  69. bool Add(object model, string overlookFieldList = "ID");
  70. #endregion
  71. #region 删除数据
  72. /// <summary>
  73. /// 删除一条数据
  74. /// </summary>
  75. bool Delete(int ID);
  76. /// <summary>
  77. /// 按ID列表批量删除数据
  78. /// </summary>
  79. /// <param name="idList">ID列表,多个用“,”分隔</param>
  80. bool DeleteList(string idList);
  81. /// <summary>
  82. /// 批量删除数据
  83. /// </summary>
  84. /// <param name="filterFieldName">筛选字段名</param>
  85. /// <param name="valueList">值列表,多个值用“,”分隔,字符串值用“'”号包含</param>
  86. bool DeleteList(string filterFieldName, string valueList);
  87. /// <summary>
  88. /// 根据筛选字段删除数据
  89. /// </summary>
  90. /// <param name="filterValue">筛选值</param>
  91. /// <param name="filterFieldName">筛选字段名</param>
  92. /// <param name="operators">筛选SQL运算符</param>
  93. /// <returns></returns>
  94. bool Delete(object filterValue, string filterFieldName = "ID", string operators = "=");
  95. /// <summary>
  96. /// 根据where条件删除数据 不建义使用此方法
  97. /// </summary>
  98. /// <param name="whereStr">Wher条件,不包含“where”关键字</param>
  99. /// <returns></returns>
  100. bool Delete(string whereStr);
  101. #endregion
  102. #region 更新数据
  103. /// <summary>
  104. /// 更新一条数据
  105. /// </summary>
  106. /// <param name="model">Model对象</param>
  107. /// <param name="filterFieldName">筛选字段名称</param>
  108. /// <param name="operators">SQL筛选运算符号</param>
  109. /// <param name="overlookFieldList">忽略字段名列表 字段名之间用“,”号分隔</param>
  110. /// <returns></returns>
  111. bool Update(object model, string filterFieldName = "ID", string operators = "=", string overlookFieldList = "ID");
  112. /// <summary>
  113. /// 根据Wher条件更新数据 不建义使用此方法
  114. /// </summary>
  115. /// <param name="model">Model对象</param>
  116. /// <param name="whereStr">Wher条件,不包含“where”关键字</param>
  117. /// <param name="overlookFieldList">忽略字段名列表 字段名之间用“,”号分隔</param>
  118. /// <returns></returns>
  119. bool Update(object model, string whereStr, string overlookFieldList = "ID");
  120. #endregion
  121. #region 查询数据
  122. /// <summary>
  123. /// 得到一个对象实体
  124. /// </summary>
  125. object GetModelObject(int ID);
  126. /// <summary>
  127. /// 得到一个对象实体
  128. /// </summary>
  129. object DataRowToModelObject(DataRow row);
  130. /// <summary>
  131. /// 根据筛选条件获取一条数据Model对象
  132. /// </summary>
  133. /// <param name="filterFieldName">筛选条件字段名</param>
  134. /// <param name="filterValue">值</param>
  135. /// <returns></returns>
  136. object GetModelObject(string filterFieldName, object filterValue);
  137. /// <summary>
  138. /// 根据筛选条件获取一条数据Model对象
  139. /// </summary>
  140. /// <param name="filterFieldName">筛选条件字段名</param>
  141. /// <param name="filterValue">值</param>
  142. /// <param name="operators">SQL筛选运算符号</param>
  143. /// <returns></returns>
  144. object GetModelObject(string filterFieldName, object filterValue, string operators);
  145. /// <summary>
  146. /// 获取一条数据DataRow对象
  147. /// </summary>
  148. /// <param name="ID">id</param>
  149. /// <returns></returns>
  150. DataRow GetDataRow(int id);
  151. /// <summary>
  152. /// 根据筛选条件获取一条数据DataRow对象
  153. /// </summary>
  154. /// <param name="filterFieldName">筛选条件字段名</param>
  155. /// <param name="filterValue">值</param>
  156. /// <param name="operators">筛选SQL运算符</param>
  157. /// <returns></returns>
  158. DataRow GetDataRow(string filterFieldName, object filterValue, string operators = "=");
  159. /// <summary>
  160. /// 根据筛选条件获取一条数据DataRow对象(运算符是“=”)
  161. /// </summary>
  162. /// <param name="filterFieldName">筛选条件字段名</param>
  163. /// <param name="filterValue">值</param>
  164. /// <returns></returns>
  165. DataRow GetDataRow(string filterFieldName, object filterValue);
  166. /// <summary>
  167. /// 得到一个对象实体
  168. /// </summary>
  169. object DataRowToModel(DataRow row, object model);
  170. /// <summary>
  171. /// 获得数据列表
  172. /// </summary>
  173. /// <param name="strWhere">条件语句 不包含 where 关键字</param>
  174. /// <param name="filedOrder">SQL排序 如:id desc</param>
  175. DataSet GetList(string strWhere, string filedOrder = "ID desc");
  176. /// <summary>
  177. /// 获得前几行数据
  178. /// </summary>
  179. /// <param name="Top">行数</param>
  180. /// <param name="strWhere">条件 不包含 where 关键字</param>
  181. /// <param name="filedOrder">SQL排序 如:id asc</param>
  182. /// <returns></returns>
  183. DataSet GetList(int Top, string strWhere, string filedOrder = "ID asc");
  184. /// <summary>
  185. /// 获得全部数据列表
  186. /// </summary>
  187. /// <param name="filedOrder">SQL排序 如:id desc</param>
  188. DataSet GetAllList(string filedOrder = "ID desc");
  189. #endregion
  190. #region 数据分页
  191. /// <summary>
  192. /// 获取分页后总页数
  193. /// </summary>
  194. /// <param name="strWhere">筛选条件</param>
  195. /// <param name="pageSize">页面大小</param>
  196. /// <returns></returns>
  197. int GetByPageCount(string strWhere, int pageSize);
  198. /// <summary>
  199. /// 获取记录总数
  200. /// </summary>
  201. int GetRecordCount(string strWhere);
  202. /// <summary>
  203. /// 分页获取数据列表
  204. /// </summary>
  205. /// <param name="strWhere">筛选条件</param>
  206. /// <param name="pageIndex">当前页 不能小于0的整数</param>
  207. /// <param name="pageSize">页面大小,每页显示条数 不能小于0的整数</param>
  208. /// <param name="orderby">排序</param>
  209. /// <returns></returns>
  210. DataSet GetListByPage(string strWhere, int pageIndex, int pageSize, string orderby = "id desc");
  211. /// <summary>
  212. /// 分页获取数据列表
  213. /// </summary>
  214. /// <param name="strWhere">筛选条件</param>
  215. /// <param name="orderby">排序</param>
  216. /// <param name="pageIndex">当前页</param>
  217. /// <param name="pageSize">页面大小,每页显示条数</param>
  218. /// <param name="pageCount">返回总页数</param>
  219. /// <returns></returns>
  220. DataSet GetListByPage(string strWhere, string orderby, int pageIndex, int pageSize, ref int pageCount);
  221. /// <summary>
  222. /// 分页获取数据列表
  223. /// </summary>
  224. /// <param name="strWhere">条件</param>
  225. /// <param name="orderby">排序</param>
  226. /// <param name="startIndex">开始index</param>
  227. /// <param name="endIndex">结束index</param>
  228. /// <returns></returns>
  229. DataSet GetListByPage(string strWhere, string orderby, int startIndex, int endIndex);
  230. #endregion
  231. }
  232. }