123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282 |
- using System;
- using System.Collections.Generic;
- using System.Text;
- using System.Data;
- namespace LYFZ.WeixinServiceDate.StandardInterface
- {
- /// <summary>
- /// 数据层基础接口
- /// </summary>
- public interface IBaseDataLaye
- {
- #region 属性
- /// <summary>
- /// 数据表模型对象
- /// </summary>
- object ObjModel { get; }
- /// <summary>
- /// 数据表名
- /// </summary>
- string TableName { get; set; }
- /// <summary>
- /// 数据表字段名字符串,字段名以“,”号分隔
- /// </summary>
- string TableFieldNameString { get; set; }
- /// <summary>
- /// 数据表字段名数组
- /// </summary>
- string[] TableFieldNames { get; }
- #endregion
- #region 检查记录
- /// <summary>
- /// 是否存在该记录
- /// </summary>
- bool Exists(int ID);
- /// <summary>
- /// 根据筛选条件判断是否存在该记录
- /// </summary>
- /// <param name="filterFieldName">筛选字段名</param>
- /// <param name="filterValue">筛选值</param>
- /// <returns></returns>
- bool Exists(string filterFieldName, object filterValue);
- /// <summary>
- /// 判断是否存某个字段
- /// </summary>
- /// <param name="columnName">列名称</param>
- /// <returns>是否存在</returns>
- bool ColumnExists(string columnName);
-
- #endregion
- #region 公共方法
- /// <summary>
- /// 获取最大ID()
- /// </summary>
- /// <returns></returns>
- int GetMaxID();
- /// <summary>
- /// 获取某字段最大值(获取字段必须为数字类型)
- /// </summary>
- /// <param name="FieldName">字段名</param>
- /// <returns></returns>
- int GetMaxID(string FieldName);
- #endregion
- #region 增加数据
- /// <summary>
- /// 增加一条数据
- /// </summary>
- /// <param name="model">Model对象</param>
- /// <param name="overlookFieldList">忽略字段名列表 字段名之间用“,”号分隔</param>
- /// <returns></returns>
- bool Add(object model, string overlookFieldList = "ID");
- /// <summary>
- /// 获取更新数据的UpdateCommandInfo对象
- /// </summary>
- /// <param name="model"></param>
- /// <param name="overlookFieldList">要忽略的字段集合 多个字段名有“,”号分隔</param>
- /// <returns></returns>
- object GetAddCommandInfoObject(object model, string overlookFieldList = "ID");
-
- #endregion
- #region 删除数据
- /// <summary>
- /// 删除一条数据
- /// </summary>
- bool Delete(int ID);
- /// <summary>
- /// 按ID列表批量删除数据
- /// </summary>
- /// <param name="idList">ID列表,多个用“,”分隔</param>
- bool DeleteList(string idList);
- /// <summary>
- /// 批量删除数据
- /// </summary>
- /// <param name="filterFieldName">筛选字段名</param>
- /// <param name="valueList">值列表,多个值用“,”分隔,字符串值用“'”号包含</param>
- bool DeleteList(string filterFieldName, string valueList);
- /// <summary>
- /// 根据筛选字段删除数据
- /// </summary>
- /// <param name="filterValue">筛选值</param>
- /// <param name="filterFieldName">筛选字段名</param>
- /// <param name="operators">筛选SQL运算符</param>
- /// <returns></returns>
- bool Delete(object filterValue, string filterFieldName = "ID", string operators = "=");
- /// <summary>
- /// 根据where条件删除数据 不建义使用此方法
- /// </summary>
- /// <param name="whereStr">Wher条件,不包含“where”关键字</param>
- /// <returns></returns>
- bool Delete(string whereStr);
- /// <summary>
- /// 根据筛选字段或where条件删除数据
- /// </summary>
- /// <param name="filterFieldName">筛选字段名</param>
- /// <param name="operators">筛选SQL运算符</param>
- /// <param name="filterValue">筛选值</param>
- /// <param name="whereStr">Wher条件,传入条件语句时筛选字段无效不建义使用 不包含“where”关键字</param>
- /// <returns></returns>
- object GetDeleteCommandInfoObject(string filterFieldName = "ID", string operators = "=", object filterValue = null, string whereStr = null);
-
- #endregion
- #region 更新数据
- /// <summary>
- /// 更新一条数据
- /// </summary>
- /// <param name="model">Model对象</param>
- /// <param name="filterFieldName">筛选字段名称</param>
- /// <param name="operators">SQL筛选运算符号</param>
- /// <param name="overlookFieldList">忽略字段名列表 字段名之间用“,”号分隔</param>
- /// <returns></returns>
- bool Update(object model, string filterFieldName = "ID", string operators = "=", string overlookFieldList = "ID");
- /// <summary>
- /// 根据Wher条件更新数据 不建义使用此方法
- /// </summary>
- /// <param name="model">Model对象</param>
- /// <param name="whereStr">Wher条件,不包含“where”关键字</param>
- /// <param name="overlookFieldList">忽略字段名列表 字段名之间用“,”号分隔</param>
- /// <returns></returns>
- bool Update(object model, string whereStr, string overlookFieldList = "ID");
- /// <summary>
- /// 获取更新数据的UpdateCommandInfo对象 根据筛选字段和SQL筛选运算符号更新数据(内部方法)
- /// </summary>
- /// <param name="model">Model对象</param>
- /// <param name="filterFieldName">筛选字段名称</param>
- /// <param name="operators">忽略字段名列表 字段名之间用“,”号分隔</param>
- /// <param name="overlookFieldList">Wher条件,当指定条件语句时筛选字段设置无效,不包含“where”关键字 不建义使用此参数</param>
- /// <param name="whereStr"></param>
- /// <returns></returns>
- object GetUpdateCommandInfoObject(object model, string filterFieldName = "ID", string operators = "=", string overlookFieldList = "ID", string whereStr = null);
-
- #endregion
- #region 查询数据
-
- /// <summary>
- /// 得到一个对象实体
- /// </summary>
- object GetModelObject(int ID);
- /// <summary>
- /// 得到一个对象实体
- /// </summary>
- object DataRowToModelObject(DataRow row);
- /// <summary>
- /// 根据筛选条件获取一条数据Model对象
- /// </summary>
- /// <param name="filterFieldName">筛选条件字段名</param>
- /// <param name="filterValue">值</param>
- /// <returns></returns>
- object GetModelObject(string filterFieldName, object filterValue);
- /// <summary>
- /// 根据筛选条件获取一条数据Model对象
- /// </summary>
- /// <param name="filterFieldName">筛选条件字段名</param>
- /// <param name="filterValue">值</param>
- /// <param name="operators">SQL筛选运算符号</param>
- /// <returns></returns>
- object GetModelObject(string filterFieldName, object filterValue, string operators);
- /// <summary>
- /// 获取一条数据DataRow对象
- /// </summary>
- /// <param name="ID">id</param>
- /// <returns></returns>
- DataRow GetDataRow(int id);
- /// <summary>
- /// 根据筛选条件获取一条数据DataRow对象
- /// </summary>
- /// <param name="filterFieldName">筛选条件字段名</param>
- /// <param name="filterValue">值</param>
- /// <param name="operators">筛选SQL运算符</param>
- /// <returns></returns>
- DataRow GetDataRow(string filterFieldName, object filterValue, string operators = "=");
- /// <summary>
- /// 根据筛选条件获取一条数据DataRow对象(运算符是“=”)
- /// </summary>
- /// <param name="filterFieldName">筛选条件字段名</param>
- /// <param name="filterValue">值</param>
- /// <returns></returns>
- DataRow GetDataRow(string filterFieldName, object filterValue);
- /// <summary>
- /// 得到一个对象实体
- /// </summary>
- object DataRowToModel(DataRow row, object model);
- /// <summary>
- /// 获得数据列表
- /// </summary>
- /// <param name="strWhere">条件语句 不包含 where 关键字</param>
- /// <param name="filedOrder">SQL排序 如:id desc</param>
- DataSet GetList(string strWhere, string filedOrder = "ID desc");
- /// <summary>
- /// 获得前几行数据
- /// </summary>
- /// <param name="Top">行数</param>
- /// <param name="strWhere">条件 不包含 where 关键字</param>
- /// <param name="filedOrder">SQL排序 如:id asc</param>
- /// <returns></returns>
- DataSet GetList(int Top, string strWhere, string filedOrder = "ID asc");
- /// <summary>
- /// 获得全部数据列表
- /// </summary>
- /// <param name="filedOrder">SQL排序 如:id desc</param>
- DataSet GetAllList(string filedOrder = "ID desc");
- #endregion
- #region 数据分页
- /// <summary>
- /// 获取分页后总页数
- /// </summary>
- /// <param name="strWhere">筛选条件</param>
- /// <param name="pageSize">页面大小</param>
- /// <returns></returns>
- int GetByPageCount(string strWhere, int pageSize);
- /// <summary>
- /// 获取记录总数
- /// </summary>
- int GetRecordCount(string strWhere);
- /// <summary>
- /// 分页获取数据列表
- /// </summary>
- /// <param name="strWhere">筛选条件</param>
- /// <param name="pageIndex">当前页 不能小于0的整数</param>
- /// <param name="pageSize">页面大小,每页显示条数 不能小于0的整数</param>
- /// <param name="orderby">排序</param>
- /// <returns></returns>
- DataSet GetListByPage(string strWhere, int pageIndex, int pageSize, string orderby = "id desc");
- /// <summary>
- /// 分页获取数据列表
- /// </summary>
- /// <param name="strWhere">筛选条件</param>
- /// <param name="orderby">排序</param>
- /// <param name="pageIndex">当前页</param>
- /// <param name="pageSize">页面大小,每页显示条数</param>
- /// <param name="pageCount">返回总页数</param>
- /// <returns></returns>
- DataSet GetListByPage(string strWhere, string orderby, int pageIndex, int pageSize, ref int pageCount);
- /// <summary>
- /// 分页获取数据列表
- /// </summary>
- /// <param name="strWhere">条件</param>
- /// <param name="orderby">排序</param>
- /// <param name="startIndex">开始index</param>
- /// <param name="endIndex">结束index</param>
- /// <returns></returns>
- DataSet GetListByPage(string strWhere, string orderby, int startIndex, int endIndex);
- #endregion
- }
- }
|