zoukankan      html  css  js  c++  java
  • linq,skip(),take实现分页

    using (AdventureWorks2012Entities db = new AdventureWorks2012Entities())
    {
    int num = (from stu in db.Customer orderby stu.CustomerID select stu).ToList().Count;

    for (int i = 0; i < num;i=i+100)
    {
    var students = (from stu in db.Customer
    orderby stu.CustomerID
    select stu).Skip(i).Take(100).ToList();
    foreach (var stu in students)
    {
    System.Diagnostics.Debug.WriteLine(stu.CustomerID + "," + stu.AccountNumber);
    }
    int pageCount = i / 100 + 1;
    System.Diagnostics.Debug.WriteLine("This is page " + pageCount + " ");
    }

    Console.ReadLine();
    }

  • 相关阅读:
    20201107
    20201024
    20201020
    20200331
    20200330
    20200320
    20200319
    20200310
    20200221
    20190926
  • 原文地址:https://www.cnblogs.com/Fred1987/p/5933590.html
Copyright © 2011-2022 走看看