Exemple #1
0
        private async Task <int> ExecuteCount(string filter, CancellationToken token)
        {
            var query = new CT.TableQuery <FatEntity>();

            if (filter != null)
            {
                query = query.Where(filter);
            }

            // Just select one column to reduce the payload significantly
            query.SelectColumns = new List <string> {
                "PartitionKey"
            };

            int count = 0;

            CT.TableQuerySegment <FatEntity> segment = null;
            do
            {
                segment = await _table.ExecuteWrap(t => t.ExecuteQuerySegmentedAsync(query, segment?.ContinuationToken, null, null, token)).ConfigureAwait(false);

                count += segment.Results.Count;
            }while (segment.ContinuationToken != null);
            return(count);
        }
Exemple #2
0
        private IAsyncEnumerable <T> ExecuteQuery(string filter, int?take)
        {
            return(AsyncEnumerableEx.Create <T>(async y =>
            {
                var query = new CT.TableQuery <FatEntity>();
                if (filter != null)
                {
                    query = query.Where(filter);
                }
                if (take.HasValue)
                {
                    query = query.Take(take);
                }

                CT.TableQuerySegment <FatEntity> segment = null;
                do
                {
                    segment = await _table.ExecuteWrap(t => t.ExecuteQuerySegmentedAsync(query, segment == null ? null : segment.ContinuationToken, null, null, y.CancellationToken)).ConfigureAwait(false);
                    foreach (var entity in segment)
                    {
                        await y.YieldReturn(ConvertFatEntity(entity)).ConfigureAwait(false);
                        y.ThrowIfCancellationRequested();
                    }
                }while (segment.ContinuationToken != null && !y.CancellationToken.IsCancellationRequested);
            }));
        }