日韩无码专区无码一级三级片|91人人爱网站中日韩无码电影|厨房大战丰满熟妇|AV高清无码在线免费观看|另类AV日韩少妇熟女|中文日本大黄一级黄色片|色情在线视频免费|亚洲成人特黄a片|黄片wwwav色图欧美|欧亚乱色一区二区三区

RELATEED CONSULTING
相關(guān)咨詢
選擇下列產(chǎn)品馬上在線溝通
服務(wù)時(shí)間:8:30-17:00
你可能遇到了下面的問題
關(guān)閉右側(cè)工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
談Linq中獲取數(shù)據(jù)分頁高效方法

今年6月初,剛參加工作,在公司做項(xiàng)目主要運(yùn)用Linq 和WCF,剛開始獲取數(shù)據(jù)列表和數(shù)據(jù)總記錄數(shù)的時(shí)候還是用了兩種方法,慢慢感覺這樣效率不高。***想出一種好的方法,今天跟大家分享一下。

專注于為中小企業(yè)提供成都網(wǎng)站設(shè)計(jì)、網(wǎng)站建設(shè)、外貿(mào)網(wǎng)站建設(shè)服務(wù),電腦端+手機(jī)端+微信端的三站合一,更高效的管理,為中小企業(yè)南城免費(fèi)做網(wǎng)站提供優(yōu)質(zhì)的服務(wù)。我們立足成都,凝聚了一批互聯(lián)網(wǎng)行業(yè)人才,有力地推動了成百上千企業(yè)的穩(wěn)健成長,幫助中小企業(yè)通過網(wǎng)站建設(shè)實(shí)現(xiàn)規(guī)模擴(kuò)充和轉(zhuǎn)變。

首先寫一個(gè)Model

 
 
 
  1. /// 
  2.          /// 封裝表中各個(gè)字段
  3.          /// 
  4.      public class Student
  5.      {
  6.          public Guid S_ID { get; set; }
  7.       
  8.          public string SJD_MC { get; set; }
  9.      
  10.          public DateTime S_Time { get; set; }
  11.         
  12.          public string S_BZ { get; set; }
  13.      }
  14.          /// 
  15.          ///將獲得全部數(shù)據(jù)跟
  16.          /// 
  17.      public class StudentList_Count
  18.      {
  19.          /// 
  20.          ///全部數(shù)據(jù)
  21.          /// 
  22.          public List StudentList{ get; set; }
  23.          /// 
  24.          ///數(shù)據(jù)的總條數(shù)
  25.          /// 
  26.          public int StudentCount { get; set; }
  27.      }
  28.          /// 
  29.          ///分頁參數(shù)
  30.          /// 
  31.      public class Student_FY : Student
  32.      {
  33.          public int PageIndex { get; set; }
  34.         
  35.          public int PageSize { get; set; }
  36.      }

然后

 
 
 
  1. public StudentList_Count StudentList(int pageIndex,int pageSize)
  2.  {
  3.              //_DB,是實(shí)例化Linq類 
  4.             var _DB = new Dal.DB_StudentDataContext();
  5.             var _Datas = from _Data in _DB.Student
  6.                              select _Data;
  7.             StudentList_Count  _DatasStuList= new StudentList_Count();
  8.             //數(shù)據(jù)總記錄數(shù)
  9.             _DatasStuList.StudentCount = _Datas.Count();
  10.             //分頁數(shù)據(jù)
  11.             _DatasStuList.StudentList = _Datas.Count() > 0 ? _Datas.Skip(pageIndex - 1) *pageSize).Take(pageSize).ToList() : null;
  12.             return _DatasStuList; 
  13.    }

網(wǎng)站欄目:談Linq中獲取數(shù)據(jù)分頁高效方法
文章來源:http://www.5511xx.com/article/dhdpdhj.html