OData service does not return full response

I am reading Sharepoint list data (> 20,000 entries) using the Odata RESTful service, as described in detail here -http: //blogs.msdn.com/b/ericwhite/archive/2010/12/09/getting-started-using- alternate OData-rest-request-a-list.aspx-SharePoint

I can read the data, but I get only the first 1000 records. I also verified that View List View was set to 5000 on the sharepoint server. Please inform.

Update:

@Turker: Your answer is in place! Many thanks. I was able to get the first 2000 entries in the first iteration. However, I get the same records in every iteration of the while loop. My code is as follows:

                         ...initial code...
                     int skipCount =0;
  while (((QueryOperationResponse)query).GetContinuation() != null)
                {
                    //query for the next partial set of customers
                    query = dc.Execute<CATrackingItem>(
                        ((QueryOperationResponse)query).GetContinuation().NextLinkUri
                        );

                    //Add the next set of customers to the full list
                    caList.AddRange(query.ToList());

                    var results = from d in caList.Skip(skipCount)
                                  select new
                                  {
                                      Actionable = Actionable,
                                    };  Created = d.Created,

                        foreach (var res in results)
                        {

                            structListColumns.Actionable = res.Actionable;
                            structListColumns.Created= res.Created;
                        }
                         skipCount = caList.Count;
                     }//Close of while loop
+3
source share
3 answers

<link rel="next"> ?

,

http://services.odata.org/Northwind/Northwind.svc/Customers/

<link rel="next" href="http://services.odata.org/Northwind/Northwind.svc/Customers/?$skiptoken='ERNSH'" />

, , ,

http://services.odata.org/Northwind/Northwind.svc/Customers/?$skiptoken='ERNSH' 

.

+6

. URL- beign, ( , - ), , ( ).

, , ( -):

DataServiceContext ctx = new DataServiceContext(new Uri("http://services.odata.org/Northwind/Northwind.svc"));

QueryOperationResponse<Customer> response = (QueryOperationResponse<Customer>)ctx.CreateQuery<Customer>("Customers").Execute();
do
{
    foreach (Customer c in response)
    {
        Console.WriteLine(c.CustomerID);
    }

    DataServiceQueryContinuation<Customer> continuation = response.GetContinuation();
    if (continuation != null)
    {
        response = ctx.Execute(continuation);
    }
    else
    {
        response = null;
    }
} while (response != null);
0

, , . DataServiceContext GetAlltems.

    public static List<T> GetAlltems<T>(this DataServiceContext context)
    {
        return context.GetAlltems<T>(null);
    }

    public static List<T> GetAlltems<T>(this DataServiceContext context, IQueryable<T> queryable)
    {
        List<T> allItems = new List<T>();
        DataServiceQueryContinuation<T> token = null;

        EntitySetAttribute attr = (EntitySetAttribute)typeof(T).GetCustomAttributes(typeof(EntitySetAttribute), false).First();

        // Execute the query for all customers and get the response object.
        DataServiceQuery<T> query = null;

        if (queryable == null)
        {
            query = context.CreateQuery<T>(attr.EntitySet);
        }
        else
        {
            query = (DataServiceQuery<T>) queryable;
        }

        QueryOperationResponse<T> response = query.Execute() as QueryOperationResponse<T>;

        // With a paged response from the service, use a do...while loop 
        // to enumerate the results before getting the next link.
        do
        {
            // If nextLink is not null, then there is a new page to load.
            if (token != null)
            {
                // Load the new page from the next link URI.
                response = context.Execute<T>(token);
            }

            allItems.AddRange(response);
        }
        // Get the next link, and continue while there is a next link.
        while ((token = response.GetContinuation()) != null);

        return allItems;
    }
0

All Articles