Пример #1
0
        /// <summary>
        /// 流程业务记录分页方法
        /// </summary>
        /// <param name="query"></param>
        /// <param name="count"></param>
        /// <returns></returns>
        public List<AppFlowEntity> GetPaged(AppFlowQuery query, out int count)
        {
            List<AppFlowEntity> list = null;
            var conn = SessionFactory.CreateConnection();

            try
            {
                var sortList = new List<DapperExtensions.ISort>();
                sortList.Add(new DapperExtensions.Sort { PropertyName = "ID", Ascending = false });

                IFieldPredicate predicate = null;
                if (!string.IsNullOrEmpty(query.AppInstanceID))
                    predicate = Predicates.Field<AppFlowEntity>(f => f.AppInstanceID, Operator.Eq, query.AppInstanceID);

                count = DBHelper.Count<AppFlowEntity>(conn, predicate);
                list = DBHelper.GetPaged<AppFlowEntity>(conn, query.PageIndex, query.PageSize,
                    predicate, sortList, false).ToList();

                return list;
            }
            catch (System.Exception)
            {
                throw;
            }
            finally
            {
                conn.Close();
            }
        }
Пример #2
0
 public ResponseResult<List<AppFlowEntity>> QueryPaged(AppFlowQuery query)
 {
     var result = ResponseResult<List<AppFlowEntity>>.Default();
     var conn = SessionFactory.CreateConnection();
     try
     {
         var count = 0;
         var list = AppFlowService.GetPaged(query, out count);
         result = ResponseResult<List<AppFlowEntity>>.Success(list);
         result.TotalRowsCount = count;
         result.TotalPages = (count + query.PageSize - 1) / query.PageSize;
     }
     catch (System.Exception ex)
     {
         result = ResponseResult<List<AppFlowEntity>>.Error(
             string.Format("获取{0}分页数据失败,错误{1}", "AppFlow", ex.Message)
         );
     }
     return result;
 }