/// <summary> /// Gets a list of tables from the storage account. /// </summary> /// <param name="select">Returns the desired properties of an entity from the set. </param> /// <param name="filter">Returns only tables or entities that satisfy the specified filter.</param> /// <param name="top">Returns only the top n tables or entities from the set.</param> /// <param name="cancellationToken">A <see cref="CancellationToken"/> controlling the request lifetime.</param> /// <returns></returns> public virtual AsyncPageable <TableItem> GetTablesAsync(string select = null, string filter = null, int?top = null, CancellationToken cancellationToken = default) { return(PageableHelpers.CreateAsyncEnumerable(async _ => { var response = await _tableOperations.QueryAsync( null, null, new QueryOptions() { Filter = filter, Select = select, Top = top, Format = _format }, cancellationToken).ConfigureAwait(false); return Page.FromValues(response.Value.Value, response.Headers.XMsContinuationNextTableName, response.GetRawResponse()); }, async(nextLink, _) => { var response = await _tableOperations.QueryAsync( null, nextTableName: nextLink, new QueryOptions() { Filter = filter, Select = select, Top = top, Format = _format }, cancellationToken).ConfigureAwait(false); return Page.FromValues(response.Value.Value, response.Headers.XMsContinuationNextTableName, response.GetRawResponse()); })); }
/// <summary> /// Gets a list of tables from the storage account. /// </summary> /// <param name="filter">Returns only tables that satisfy the specified filter.</param> /// <param name="maxPerPage"> /// The maximum number of tables that will be returned per page. /// Note: This value does not limit the total number of results if the result is fully enumerated. /// </param> /// <param name="cancellationToken">A <see cref="CancellationToken"/> controlling the request lifetime.</param> /// <returns>An <see cref="AsyncPageable{T}"/> containing a collection of <see cref="TableItem"/>s.</returns> public virtual AsyncPageable <TableItem> GetTablesAsync(string filter = null, int?maxPerPage = null, CancellationToken cancellationToken = default) { return(PageableHelpers.CreateAsyncEnumerable( async pageSizeHint => { using DiagnosticScope scope = _diagnostics.CreateScope($"{nameof(TableServiceClient)}.{nameof(GetTables)}"); scope.Start(); try { var response = await _tableOperations.QueryAsync( null, new QueryOptions() { Filter = filter, Select = null, Top = pageSizeHint, Format = _format }, cancellationToken) .ConfigureAwait(false); return Page.FromValues(response.Value.Value, response.Headers.XMsContinuationNextTableName, response.GetRawResponse()); } catch (Exception ex) { scope.Failed(ex); throw; } }, async(nextLink, pageSizeHint) => { using DiagnosticScope scope = _diagnostics.CreateScope($"{nameof(TableServiceClient)}.{nameof(GetTables)}"); scope.Start(); try { var response = await _tableOperations.QueryAsync( nextTableName: nextLink, new QueryOptions() { Filter = filter, Select = null, Top = pageSizeHint, Format = _format }, cancellationToken) .ConfigureAwait(false); return Page.FromValues(response.Value.Value, response.Headers.XMsContinuationNextTableName, response.GetRawResponse()); } catch (Exception ex) { scope.Failed(ex); throw; } }, maxPerPage)); }