/// <summary> /// Load List of all DisabledCustomer objects from Context for Partition Key. /// </summary> /// <param name="p_Partition">Partition key of the table</param> /// <returns>List of all DisabledCustomer </returns> public List<DisabledCustomer> GetAllForPartition( string PartitionKey ) { List<DisabledCustomer> rez = new List<DisabledCustomer>(); NextRecordInfo nextRec = new NextRecordInfo() ; do { DataServiceQuery<DisabledCustomers> Qtran = (DataServiceQuery<DisabledCustomers>)servCtx.CreateQuery<DisabledCustomers>(TableName).Where(c => c.PartitionKey == PartitionKey); nextRec = GetNextPage(ref rez, Qtran, nextRec, 0); } while (!string.IsNullOrEmpty(nextRec.NextPartition)); return rez; }
/// <summary> /// Load next page of DisabledCustomer 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<DisabledCustomer> list, DataServiceQuery<DisabledCustomers> 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<DisabledCustomers>)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<DisabledCustomers> qt = (IQueryable<DisabledCustomers>)qor.AsQueryable(); Result.NextKey = nextRow; Result.NextPartition = nextPartition; var enumer = qt.GetEnumerator(); while (enumer.MoveNext()) list.Add( new DisabledCustomer(enumer.Current)); return Result; }