状态中缺少分页属性

时间:2013-07-24 17:33:27

标签: linq-to-twitter

在最新版本的LINQ to Twitter v2.1.08中,不再支持分页。如何获取没有页面属性的特定页面?

干杯

int curPageIndex=5;
string pageindex="5";
string cmd = "next";
using (var twitterCtx = new TwitterContext(myauth))
  {
    try
    {
      // set up the "main query"
      IQueryable<Status> test = from tweet in twitterCtx.Status select tweet;


      switch (cmd)
      {
        case "prev":

          test = pageindex.Length > 0
                   ? test.Where(p => p.Type == StatusType.Home && p.Page == curPageIndex)                       
                   : test.Where(p => p.Type == StatusType.Home);
          break;
        case "next":
          test = pageindex.Length > 0
                   ? test.Where(p => p.Type == StatusType.Home && p.Page == curPageIndex)                       
                   : test.Where(p => p.Type == StatusType.Home);
          break;
        default:              
          //
          test = test.Where(p => p.Type == StatusType.Home);
          break;
      }        

1 个答案:

答案 0 :(得分:1)

解决方案:将Page参数更改为SinceID和MaxID

//Get the statusids in the query, add or subtract so you skip current id's
ulMaxId = test.Min(status => ulong.Parse(status.StatusID)) - 1;
ulSinceID = test.Max(status => ulong.Parse(status.StatusID)) + 1;

//Return ID above and use them in future calls (below)

//Now you can navigate timelines, depending if you are stepping forward or backwards

? test.Where(p => p.Type == StatusType.Home && p.SinceID == ulong.Parse(sinceid)
...
? test.Where(p => p.Type == StatusType.Home && p.MaxID == ulong.Parse(maxid))