zoukankan      html  css  js  c++  java
  • 数据量太大时,如何实现分页查询-CSOM

    static List<ListItem> getEmployee()
    {
    string account = ConfigurationManager.AppSettings["account"];
    string password = ConfigurationManager.AppSettings["password"];
    string empUrl = ConfigurationManager.AppSettings["empUrl"];
    using(ClientContext ctx=new ClientContext(empUrl)){
    SecureString securepassWord = new SecureString();
    foreach (char c in password.ToCharArray())
    {
    securepassWord.AppendChar(c);
    }
    ctx.Credentials = new SharePointOnlineCredentials(account, securepassWord);//针对online的验证
    List<ListItem> employeeItem = new List<ListItem>();
    List employee = ctx.Web.Lists.GetByTitle("llistName");
    CamlQuery camlQuery = new CamlQuery();
    camlQuery.ViewXml = "<View>"
    //+ "<Query><Where>"
    //+ "<And>"
    //+ "<IsNotNull><FieldRef Name='column1'/></IsNotNull>"
    //+ "<And>"
    //+ "<Eq><FieldRef Name='column2'/><Value Type='Text'>A</Value></Eq>"
    //+ "<Eq><FieldRef Name='column3'/><Value Type='Text'>Y</Value></Eq>"
    //+ "</And>"
    //+ "</And>"
    //+ "</Where></Query>"
    + "<ViewFields>"
    + "<FieldRef Name='column1'/>"
    + "<FieldRef Name='column2'/>"
    + "<FieldRef Name='column3'/>"
    + "<FieldRef Name='column4'/>"
    + "<FieldRef Name='column5'/>"
    + "</ViewFields>"
    + "<RowLimit>5000</RowLimit>"
    +"</View>";
    ListItemCollectionPosition position = null;
    do
    {
    camlQuery.ListItemCollectionPosition = position; 
    ListItemCollection empColl = employee.GetItems(camlQuery);
    ctx.Load(empColl);
    ctx.Load(empColl, items => items.Include(item => item["column1"], item => item["column2"], item => item["column3"], item => item["column4"], item => item["column5"]));
    ctx.ExecuteQuery();
    position = empColl.ListItemCollectionPosition;
    if (empColl.Count>0)
    employeeItem.AddRange(empColl.ToList());
    } while (position != null); 
    return employeeItem;
    }
    }
  • 相关阅读:
    BZOJ1187 [HNOI2007]神奇游乐园(插头dp)
    BZOJ4926 皮皮妖的递推
    BZOJ3684 大朋友和多叉树(多项式相关计算)
    BZOJ4574 [Zjoi2016]线段树
    杜教筛进阶+洲阁筛讲解+SPOJ divcnt3
    从几场模拟考试看一类分块算法
    bzoj3142 luogu3228 HNOI2013 数列
    luogu3244 bzoj4011 HNOI2015 落忆枫音
    codeforces 286E Ladies' Shop
    BZOJ4825 单旋
  • 原文地址:https://www.cnblogs.com/learning-life/p/10405333.html
Copyright © 2011-2022 走看看