/// <summary> /// Test point queries entities inside and outside the given range. /// </summary> /// <param name="testClient">The table client to test.</param> /// <param name="tableName">The name of the table to test.</param> /// <param name="accessPermissions">The access permissions of the table client.</param> /// <param name="startPk">The start partition key range.</param> /// <param name="startRk">The start row key range.</param> /// <param name="endPk">The end partition key range.</param> /// <param name="endRk">The end row key range.</param> private void TestPointQuery( CloudTableClient testClient, string tableName, SharedAccessTablePermissions accessPermissions, string startPk, string startRk, string endPk, string endRk) { Action <BaseEntity> queryDelegate = (tableEntity) => { TableServiceContext context = testClient.GetTableServiceContext(); TableServiceQuery <BaseEntity> query = (from entity in context.CreateQuery <BaseEntity>(tableName) where entity.PartitionKey == tableEntity.PartitionKey && entity.RowKey == tableEntity.RowKey select entity).AsTableServiceQuery(context); IEnumerable <BaseEntity> list = query.Execute().ToList(); Assert.AreEqual(1, list.Count()); BaseEntity e = list.Single(); }; bool expectSuccess = (accessPermissions & SharedAccessTablePermissions.Query) != 0; // Perform test TestOperationWithRange( tableName, startPk, startRk, endPk, endRk, queryDelegate, "point query", expectSuccess, expectSuccess ? HttpStatusCode.OK : HttpStatusCode.NotFound); }
public static async Task <ReadOnlyCollection <T> > ExecuteSegmentedAsync <T>(this TableServiceQuery <T> query, IProgress <List <T> > progress = null, CancellationToken cancellationToken = default(CancellationToken)) { TableQuerySegment <T> resultSegment; TableContinuationToken continuation = null; var results = new List <T>(); do { resultSegment = await Task.Factory.FromAsync( (cb, state) => query.BeginExecuteSegmented(continuation, cb, state).WithCancellation(cancellationToken), ar => query.EndExecuteSegmented(ar), null); results.AddRange(resultSegment.Results); if (progress != null) { progress.Report(resultSegment.Results); } continuation = resultSegment.ContinuationToken; } while (continuation != null); return(new ReadOnlyCollection <T>(results)); }