예제 #1
0
        public static async Task <PagedListResult <TOutput> > PaginateListResult <TInput, TOutput>(
            this CloudTable table,
            TableQuery <TInput> query,
            Func <TInput, TOutput> conversion,
            CloudTableBasedContinuationToken continuationToken,
            CancellationToken cancelationToken = default(CancellationToken))
            where TInput : ITableEntity, new()
        {
            var items = new List <TOutput>();
            TableContinuationToken token = continuationToken.IsContinuation() ? continuationToken.TableCursor : null;
            var oc = new OperationContext();
            var ro = new TableRequestOptions();

            var seg = await table.ExecuteQuerySegmentedAsync(query, token, ro, oc, cancelationToken);

            continuationToken.TableCursor = seg.ContinuationToken;
            items.AddRange(
                seg.Select(x => conversion(x))
                .Where(x => x != null)
                );

            return(new PagedListResult <TOutput> {
                Items = items, ContinuationToken = continuationToken?.IntoToken()
            });
        }
예제 #2
0
 public static Task <PagedListResult <TOutput> > PaginateListResult <TInput, TOutput>(
     this CloudTable table,
     TableQuery <TInput> query,
     int pageSize,
     Func <TInput, TOutput> conversion,
     CloudTableBasedContinuationToken continuationToken,
     CancellationToken cancelationToken = default(CancellationToken))
     where TInput : ITableEntity, new()
 {
     return(table.PaginateListResultAsync(query, pageSize, x => Task.FromResult(conversion(x)), continuationToken, cancelationToken));
 }
예제 #3
0
        public async Task <PagedListResult <FeatureDetail> > GetFeatures(string continuationToken)
        {
            if (newGates_)
            {
                var table = featureStore_.Value.Storage;
                var query = new Microsoft.Azure.Cosmos.Table.TableQuery <FeatureEntryTableEntity>()
                            .Where(Microsoft.Azure.Cosmos.Table.TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.Equal, FeatureGateStore.GatePartitionKey));
                var token = new CosmosTableBasedContinuationToken(continuationToken);

                return(await table.PaginateListResultAsync(query, 30, x => Task.FromResult(x.To <FeatureEntry>().ToFeatureDetail()), token));
            }
            else
            {
                var table = featureStore_.Value.GatesTable.Table;
                var query = new TableQuery <LegacyFeatureEntry>()
                            .Where(TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.Equal, FeatureGateStore.GatePartitionKey));
                var token = new CloudTableBasedContinuationToken(continuationToken);

                return(await table.PaginateListResult(query, x => x.ToFeatureDetail(), token));
            }
        }