1

在最新版本的 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;
      }        

4

1 回答 1

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))
于 2013-07-25T08:49:36.203 回答