Exemplo n.º 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.ExecuteQuerySegmentedAsync(query, segment?.ContinuationToken, token);

                count += segment.Results.Count;
            }while (segment.ContinuationToken != null);
            return(count);
        }
Exemplo n.º 2
0
        private async IAsyncEnumerable <T> ExecuteQuery(string filter, int?take, [EnumeratorCancellation] CancellationToken token = default)
        {
            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.ExecuteQuerySegmentedAsync(query, segment == null?null : segment.ContinuationToken, token);

                foreach (var entity in segment)
                {
                    yield return(ConvertFatEntity(entity));

                    if (token.IsCancellationRequested)
                    {
                        break;
                    }
                }
            }while (segment.ContinuationToken != null && !token.IsCancellationRequested);
        }