public async virtual Task <Response <IReadOnlyList <ServerDatabaseAdvisor> > > GetAllAsync(string expand = null, CancellationToken cancellationToken = default) { using var scope = _clientDiagnostics.CreateScope("ServerDatabaseAdvisorCollection.GetAll"); scope.Start(); try { var response = await _databaseAdvisorsRestClient.ListByDatabaseAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, expand, cancellationToken).ConfigureAwait(false); return(Response.FromValue(response.Value.Select(value => new ServerDatabaseAdvisor(Parent, value)).ToArray() as IReadOnlyList <ServerDatabaseAdvisor>, response.GetRawResponse())); } catch (Exception e) { scope.Failed(e); throw; } }
public virtual AsyncPageable <ServerDatabaseAdvisor> GetAllAsync(string expand = null, CancellationToken cancellationToken = default) { async Task <Page <ServerDatabaseAdvisor> > FirstPageFunc(int?pageSizeHint) { using var scope = _serverDatabaseAdvisorDatabaseAdvisorsClientDiagnostics.CreateScope("ServerDatabaseAdvisorCollection.GetAll"); scope.Start(); try { var response = await _serverDatabaseAdvisorDatabaseAdvisorsRestClient.ListByDatabaseAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, expand, cancellationToken : cancellationToken).ConfigureAwait(false); return(Page.FromValues(response.Value.Select(value => new ServerDatabaseAdvisor(ArmClient, value)), null, response.GetRawResponse())); } catch (Exception e) { scope.Failed(e); throw; } } return(PageableHelpers.CreateAsyncEnumerable(FirstPageFunc, null)); }