/// <summary> /// Load next page of UserDevice objects from Context for the passed in query and /// adds this page to passed in lis. /// </summary> /// <param name="list">List results will be added to.</param> /// <param name="Query">DataServiceQuery object</param> /// <param name="nextRec"> NextRecordInfo object define begining of the page to load</param> /// <param name="PageSize">Size of the page. If value is 0 or value greater than 1000 system will limit paze size to 1000 records </param> /// <returns> NextRecordInfo object for the next page</returns> private NextRecordInfo GetNextPage(ref List<UserDevice> list, DataServiceQuery<UserDevices> Query, NextRecordInfo nextRec, int PageSize) { NextRecordInfo Result = new NextRecordInfo(); QueryOperationResponse qor; if (!string.IsNullOrEmpty(nextRec.NextPartition)) Query = Query.AddQueryOption("NextPartitionKey", nextRec.NextPartition).AddQueryOption("NextRowKey", nextRec.NextKey); if (PageSize > 0) qor = (QueryOperationResponse)((DataServiceQuery<UserDevices>)Query.Take(PageSize)).Execute(); else qor = (QueryOperationResponse)(Query).Execute(); string nextPartition = String.Empty; string nextRow = String.Empty; qor.Headers.TryGetValue("x-ms-continuation-NextPartitionKey", out nextPartition); qor.Headers.TryGetValue("x-ms-continuation-NextRowKey", out nextRow); IQueryable<UserDevices> qt = (IQueryable<UserDevices>)qor.AsQueryable(); Result.NextKey = nextRow; Result.NextPartition = nextPartition; var enumer = qt.GetEnumerator(); while (enumer.MoveNext()) list.Add( new UserDevice(enumer.Current)); return Result; }