1. 程式人生 > >【C#公共幫助類】分頁邏輯處理類

【C#公共幫助類】分頁邏輯處理類

  1 using System;
  2 using System.Collections.Generic;
  3 using System.Linq;
  4 using System.Text;
  5 
  6 namespace Common
  7 {
  8     /// <summary>
  9     /// 分頁邏輯處理類
 10     /// </summary>
 11     public class PageCollection
 12     {
 13         /// <summary>
 14         ///
總頁數 15 /// </summary> 16 public int TotalPages { get; set; } 17 /// <summary> 18 /// 當前頁面 19 /// </summary> 20 public int CurrentPage { get; set; } 21 /// <summary> 22 /// 每頁的記錄數 23 /// </summary> 24 public
int OnePageSize { get; set; } 25 /// <summary> 26 /// 總記錄數 27 /// </summary> 28 public long TotalRows { get; set; } 29 /// <summary> 30 /// 排序 31 /// </summary> 32 public string OrderBy { get; set; } 33 34 ///
<summary> 35 /// 構造無參預設為最大數 36 /// </summary> 37 public PageCollection() 38 { 39 this.CurrentPage = 0; 40 this.OnePageSize = 20;//預設最大行數20條 41 } 42 } 43 /// <summary> 44 /// 分頁邏輯處理類 linq to entites 45 /// </summary> 46 public class PageInfo<TEntity> where TEntity : class 47 { 48 public PageInfo(int index, int pageSize, int count, List<TEntity> list,string url="") 49 { 50 Index = index; 51 PageSize = pageSize; 52 Count = count; 53 List = list; 54 Url = url; 55 //計算資料條數從開始到結束的值 56 if (count == 0) 57 { 58 BeginPage = 0; 59 EndPage = 0; 60 } 61 else 62 { 63 int maxpage = count / pageSize; 64 65 if (count % pageSize > 0) 66 { 67 maxpage++; 68 } 69 if (index >= maxpage) 70 { 71 index = maxpage; 72 73 BeginPage = pageSize * index - pageSize + 1; 74 EndPage = count; 75 } 76 else 77 { 78 BeginPage = pageSize * index - pageSize + 1; 79 EndPage = pageSize * index; 80 } 81 } 82 } 83 84 public int Index { get; private set; } 85 public int PageSize { get; private set; } 86 public int Count { get; private set; } 87 public List<TEntity> List { get; set; } 88 public string Url { get; set; } 89 public int BeginPage { get; private set; } 90 public int EndPage { get; private set; } 91 } 92 93 /// <summary> 94 /// 分頁邏輯處理類 dynamic 95 /// </summary> 96 public class PageInfo 97 { 98 public PageInfo(int index, int pageSize, int count, dynamic list, string url = "") 99 { 100 Index = index; 101 PageSize = pageSize; 102 Count = count; 103 List = list; 104 Url = url; 105 //計算資料條數從開始到結束的值 106 if (count == 0) 107 { 108 BeginPage = 0; 109 EndPage = 0; 110 } 111 else 112 { 113 int maxpage = count / pageSize; 114 115 if (count % pageSize > 0) 116 { 117 maxpage++; 118 } 119 if (index >= maxpage) 120 { 121 index = maxpage; 122 123 BeginPage = pageSize * index - pageSize + 1; 124 EndPage = count; 125 } 126 else 127 { 128 BeginPage = pageSize * index - pageSize + 1; 129 EndPage = pageSize * index; 130 } 131 } 132 } 133 134 public int Index { get; private set; } 135 public int PageSize { get; private set; } 136 public int Count { get; private set; } 137 public dynamic List { get; private set; } 138 public string Url { get; set; } 139 public int BeginPage { get; private set; } 140 public int EndPage { get; private set; } 141 } 142 143 /// <summary> 144 /// Eazyui分頁處理邏輯類 145 /// </summary> 146 public class PageEazyUi 147 { 148 public PageEazyUi(int _page, int _pagesize, int _total, object _rows) 149 { 150 page = _page; 151 pagesize = _pagesize; 152 total = _total; 153 rows = _rows; 154 } 155 156 public int page { get; private set; } 157 public int pagesize { get; private set; } 158 public int total { get; private set; } 159 public object rows { get; private set; } 160 } 161 }

相關推薦

C#公共幫助邏輯處理

1 using System; 2 using System.Collections.Generic; 3 using System.Linq; 4 using System.Text; 5 6 namespace Common 7 { 8 ///

C#公共幫助 WebHelper幫助

1 using System; 2 using System.Data; 3 using System.Configuration; 4 using System.Web; 5 using System.Web.Security; 6 using System.Web.U

C#公共幫助給大家分享一些加密演算法 (DES、HashCode、RSA、AES等)

AES       高階加密標準(英語:Advanced Encryption Standard,縮寫:AES),在密碼學中又稱Rijndael加密法,是美國聯邦政府採用的一種區塊加密標準。這個標準用來替代原先的DES,已經被多方分析且廣為全世界所使用。AES先進加密演算法是一向被認為牢不可破的加密演算法,

C#公共幫助 Log4net 幫助

1 using log4net.Core; 2 using System; 3 using System.Collections.Generic; 4 using System.Linq; 5 using System.Reflection; 6 using System

C#公共幫助JsonHelper 操作幫助, 以後再也不用滿地找Json了,拿來直接用

using System; using System.Collections.Generic; using System.Text; using System.Data; using System.Linq; using System.Web.Script.Serialization; usi

C#公共幫助列舉獨特

1 using System; 2 using System.Collections.Generic; 3 using System.Linq; 4 using System.Text; 5 using System.ComponentModel; 6 7 nam

C#公共幫助 ToolsHelper幫助

1 using System; 2 using System.Text; 3 using System.Text.RegularExpressions; 4 using System.Collections.Generic; 5 using System.Reflection;

CI框架原始碼解析之檔案Pagination.php

<?php /** * ======================================= * Created by Pocket Knife Technology. * User: ZhiHua_W * Date: 2016/11/08 0

Flask 第五篇

__init__ gen object nta container lock main previous boot 一、flask實現的分頁組件 from urllib.parse import urlencode,quote,unquote class Paginat

Django Restful Framework第五篇、視圖、路由、渲染器

framework 增刪改查 format conf apn register ali dmi elf 一、分頁 試問如果當數據量特別大的時候,你是怎麽解決分頁的? 方式a、記錄當前訪問頁數的數據id 方式b、最多顯示120頁等 方式c、只顯示上一頁,下一頁,不讓選擇頁

C#復習總結匿名型由來

數據類型 over 無效 訪問性 屬性。 知乎 私有 不能 默認構造函數 1 屬性 這得先從屬性開始說,為什麽外部代碼訪問對象內部的數據用屬性而不是直接訪問呢,這樣豈不是更方便一些,但是事實證明直接訪問是不安全的。那麽,Anders Hejlsberg(安德斯&mid

轉載整理

整理 alt www pre spa 翻頁 分頁查詢 限定 service 1 條件優化 加入限定(記錄之前頁信息) https://zhuanlan.zhihu.com/p/26043916 LIMIT 語句 分頁查詢是最常用的場景之一,但也通常也是最容易出問題的地

小程式載入資料,下拉載入更多,上拉重新整理

【 小程式】分頁載入資料,下拉載入更多,上拉重新整理 分頁載入的優點就不多說了,下面主要記錄一下幾個問題點。 scroll-view元件不能用在頁面根佈局中,不然觸發不了系統的onPullDownRefresh()、onReachBottom()回撥。 在Page頁

java小程式顯示視訊列表

###內容目錄(由[TOC]自動生成) 文章目錄 分頁查詢的後端程式碼 小程式端程式碼 index.wxml index.wxss index.js

Web簡單實現

web分頁 為什麼需要分頁? 一、資料方面的原因 大量查詢的資料耗時比較嚴重。 二、增強使用者使用體驗需求 使用者更方便的查詢和展示他所需要的資料。 常見分頁方式:傳統分頁方式和下拉式分頁方式。 採用傳統的分頁方式,可以明確的獲取資料資訊,如有多少條資料,分多少頁顯示。

C#多執行緒1.Thread的使用及注意要點

Thread隨便講講   因為在C#中,Thread類在我們的新業務上並不常用了(因為建立一個新執行緒要比直接從執行緒池拿執行緒更加耗費資源),並且在.NET4.0後新增了Task類即Async與await關鍵字,使得我們基本不再用Thread了,不過在學習多執行緒前,有必要先了解下Thread類,這裡就先隨

mybatis-plus邏輯刪除

通過mybatis-plus實現分頁,也是很簡單,外掛大法。 ### 一、分頁 #### 1、配置分頁外掛 把分頁的外掛也配置到統一的配置類裡: ``` @Configuration // 配置掃描mapper的路徑 @MapperScan("com.pingguo.mpdemo.mapper") publ

C++/數據結構單鏈表的基本操作

clear default als troy pub 插入 else fonts pac #pragma once #ifndef _CLIST_H_ #define _CLIST_H_ #include <iostream> #include <

HTTP模擬工具C#/Winform源碼、Json綁定TreeView控件、使用了MetroModernUI、RestSharp、Dapper.Net、Newtonsoft.Json、SmartThreadPool這幾個主要開源框架

type form num -m 請求 resource dap bool dev HTTP模擬工具 開發語言:C#/Winform開發工具:Visual Studio 2017數據庫: SQLite使用框架:界面-MetroModernUI

java實現功能的

oid gen asf agen pre 首頁 != eno true package smn.util; public class Pager { private int pageNow; private int pageSize=4; pri