コード例 #1
0
        /// <summary>
        /// 批量删除数据
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="ids">主键数组</param>
        /// <returns>影响行数</returns>
        public int BatchDelete(UserInfo userInfo, string[] ids)
        {
            var returnValue = 0;
            var parameter   = ParameterUtil.CreateWithMessage(userInfo, MethodBase.GetCurrentMethod(), this.serviceName, "批量删除数据");

            ServiceUtil.ProcessBusinessDb(userInfo, parameter, dbProvider =>
            {
                returnValue = new testdemoManager(dbProvider, userInfo).Delete(ids);
            });
            return(returnValue);
        }
コード例 #2
0
        /// <summary>
        /// 得到实体
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="id">主鍵</param>
        /// <returns>实体</returns>
        public testdemoEntity GetEntity(UserInfo userInfo, string id)
        {
            testdemoEntity entity    = null;
            var            parameter = ParameterUtil.CreateWithOutMessage(userInfo, MethodBase.GetCurrentMethod(), this.serviceName);

            ServiceUtil.ProcessBusinessDb(userInfo, parameter, dbProvider =>
            {
                entity = new testdemoManager(dbProvider, userInfo).GetEntity(id);
            });
            return(entity);
        }
コード例 #3
0
        /// <summary>
        /// 根据条件获取数据
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="parameters">参数</param>
        /// <returns>数据表</returns>
        public DataTable GetDTByValues(UserInfo userInfo, List <KeyValuePair <string, object> > parameters)
        {
            var dataTable = new DataTable(testdemoTable.TableName);
            var parameter = ParameterUtil.CreateWithOutMessage(userInfo, MethodBase.GetCurrentMethod(), this.serviceName);

            ServiceUtil.ProcessBusinessDb(userInfo, parameter, dbProvider =>
            {
                dataTable           = new testdemoManager(dbProvider, userInfo).GetDT(parameters);
                dataTable.TableName = testdemoTable.TableName;
            });
            return(dataTable);
        }
コード例 #4
0
        /// <summary>
        /// 获取列表
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <returns>数据表</returns>
        public DataTable GetDT(UserInfo userInfo)
        {
            var dataTable = new DataTable(testdemoTable.TableName);
            var parameter = ParameterUtil.CreateWithOutMessage(userInfo, MethodBase.GetCurrentMethod(), this.serviceName);

            ServiceUtil.ProcessBusinessDb(userInfo, parameter, dbProvider =>
            {
                dataTable           = new testdemoManager(dbProvider, userInfo).GetDT(testdemoTable.FieldID);
                dataTable.TableName = testdemoTable.TableName;
            });
            return(dataTable);
        }
コード例 #5
0
        /// <summary>
        /// 分页获取列表
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="searchValue">查询关键字</param>
        /// <param name="recordCount">记录数</param>
        /// <param name="pageIndex">当前页</param>
        /// <param name="pageSize">每页显示记录条数</param>
        /// <param name="sortExpression">排序字段</param>
        /// <returns>数据表</returns>
        public List <testdemoEntity> GetListByPage(UserInfo userInfo, string searchValue, out int recordCount, int pageIndex = 1, int pageSize = 20, string sortExpression = null)
        {
            List <testdemoEntity> list = new List <testdemoEntity>();
            var returnRecordCount      = 0;
            var parameter = ParameterUtil.CreateWithOutMessage(userInfo, MethodBase.GetCurrentMethod(), this.serviceName);

            ServiceUtil.ProcessBusinessDb(userInfo, parameter, dbProvider =>
            {
                var manager   = new testdemoManager(dbProvider, userInfo);
                var dataTable = manager.GetDTByPage(out returnRecordCount, pageIndex, pageSize, searchValue, sortExpression);
                list          = BaseEntity.GetList <testdemoEntity>(dataTable);
            });
            recordCount = returnRecordCount;
            return(list);
        }
コード例 #6
0
        /// <summary>
        /// 新增
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="entity">实体</param>
        /// <param name="statusCode">返回状态码</param>
        /// <param name="statusMessage">返回状态消息</param>
        /// <returns>主鍵</returns>
        public string Add(UserInfo userInfo, testdemoEntity entity, out string statusCode, out string statusMessage)
        {
            var    returnValue   = string.Empty;
            string returnCode    = string.Empty;
            string returnMessage = string.Empty;
            var    parameter     = ParameterUtil.CreateWithMessage(userInfo, MethodBase.GetCurrentMethod(), this.serviceName, "新增实体");

            ServiceUtil.ProcessBusinessDb(userInfo, parameter, dbProvider =>
            {
                var manager = new testdemoManager(dbProvider, userInfo);
                returnValue = manager.Add(entity);
                // returnValue = manager.Add(entity, out returnCode);
                returnMessage = manager.GetStateMessage(returnCode);
            });
            statusCode    = returnCode;
            statusMessage = returnMessage;
            return(returnValue);
        }