Exemple #1
0
        private void RemovePageWithChildPages(TableServiceContext serviceContext, PageEntity entity)
        {
            serviceContext.DeleteObject(entity);

            var children = serviceContext.CreateQuery <PageEntity>(PageTable)
                           .Where(it => it.PartitionKey == entity.SiteName && it.ParentPage == entity.FullName)
                           .ToArray();

            foreach (var item in children)
            {
                RemovePageWithChildPages(serviceContext, item);
            }
        }
        private void LoadAllBooksThatStartWithTheLetterC()
        {
            // Load all books that start with the letter "C" using a partition scan...

            CloudTableClient    tableClient  = storageAccount.CreateCloudTableClient();
            TableServiceContext tableContext = tableClient.GetDataServiceContext();

            tableClient.CreateTableIfNotExist("Book");

            Refresh(
                tableContext.CreateQuery <Book>("Book").Where(
                    b => (b.RowKey.CompareTo("C") >= 0) && (b.RowKey.CompareTo("D") < 0)).AsTableServiceQuery());
        }
Exemple #3
0
        private List <TradingPartnerSpecCertMetadata> GetAllTradingPartnerSpecCert()
        {
            this.tableClient = account.CreateCloudTableClient();
            this.tableClient.CreateTableIfNotExist(TradingPartnerSpecCertTableName);
            this.tableContext = tableClient.GetDataServiceContext();

            List <TradingPartnerSpecCertMetadata> tradingPartnerSpecCerts =
                (from tradingPartnerSpecCertMetadata in
                 tableContext.CreateQuery <TradingPartnerSpecCertMetadata>(TradingPartnerSpecCertTableName)
                 select tradingPartnerSpecCertMetadata).ToList();

            return(tradingPartnerSpecCerts);
        }
Exemple #4
0
        private List <BtsAssemblyFilesMetadata> GetAllBtsAssemblyFiles()
        {
            this.tableClient = account.CreateCloudTableClient();
            this.tableClient.CreateTableIfNotExist(MapFilesTableName);
            this.tableContext = tableClient.GetDataServiceContext();

            List <BtsAssemblyFilesMetadata> btsAssemblyFiles =
                (from mapFilesMetadata in
                 tableContext.CreateQuery <BtsAssemblyFilesMetadata>(MapFilesTableName)
                 select mapFilesMetadata).ToList();

            return(btsAssemblyFiles);
        }
        private List <BizRuleCertMetadata> GetAllBizRuleCert()
        {
            this.tableClient = account.CreateCloudTableClient();
            this.tableClient.CreateTableIfNotExist(BizRuleCertTableName);
            this.tableContext = tableClient.GetDataServiceContext();

            List <BizRuleCertMetadata> bizRuleCerts =
                (from bizRuleCertMetadata in
                 tableContext.CreateQuery <BizRuleCertMetadata>(BizRuleCertTableName)
                 select bizRuleCertMetadata).ToList();

            return(bizRuleCerts);
        }
Exemple #6
0
        public IEnumerable <FileEntity> GetFilesMetadata(IEnumerable <string> rowKeys)
        {
            TableServiceContext tableContext = GetTableContext();

            foreach (var rowKey in rowKeys)
            {
                var fileEntity = (from file in tableContext.CreateQuery <FileEntity>(MetadataTable)
                                  //where file.RowKey == rowKey
                                  select file).Single();

                yield return(fileEntity);
            }
        }
Exemple #7
0
        // Table will come back sorted by (parition, row key)
        // Integers don't sort nicely as strings.
        public static T[] ReadTable <T>(CloudStorageAccount account, string tableName) where T : TableServiceEntity
        {
            CloudTableClient    tableClient = account.CreateCloudTableClient();
            TableServiceContext ctx         = tableClient.GetDataServiceContext();


            var query  = from row in ctx.CreateQuery <T>(tableName) select row;
            var query2 = query.AsTableServiceQuery <T>();

            // Verify table matches source
            T[] result = query2.ToArray();

            return(result);
        }
Exemple #8
0
        public ActionResult Index(string continent)
        {
            TableServiceContext tableContext = GetTableContext();
            List <Country>      countries;

            if (string.IsNullOrEmpty(continent))
            {
                // No specific continent required. Retrieve entire table content
                countries = tableContext
                            .CreateQuery <Country>(CountriesTable).ToList();
            }
            else
            {
                // Filter by continent
                IQueryable <Country> query =
                    from e in tableContext.CreateQuery <Country>(CountriesTable)
                    where e.PartitionKey == continent
                    select e;

                countries = query.ToList();
            }

            return(View(countries));
        }
Exemple #9
0
        public void Process()
        {
            while (true)
            {
                var filesNoThumbnail = _ctx.CreateQuery <FileEntity>(_filesTable.Name)
                                       //.Where(fe => fe.ThumbnailUrl == null)
                                       .AsTableServiceQuery <FileEntity>(_ctx).ToList().Where(fe => fe.ThumbnailUrl == null).ToList();

                if (filesNoThumbnail.Count > 0)
                {
                    foreach (var file in filesNoThumbnail)
                    {
                        if (file.RowKey.Split('.')[1] == "png")
                        {
                            continue;
                        }
                        var blob = _photoContainer.GetBlockBlobReference(file.RowKey);

                        var imageStream = new MemoryStream();
                        blob.DownloadToStream(imageStream);
                        imageStream.Seek(0, SeekOrigin.Begin);
                        try
                        {
                            //load and resize image
                            var thumbnail = LoadImageFromStream(imageStream);
                            imageStream.Close();
                            imageStream.Dispose();

                            //save the thumbnail
                            var thumbnailStream = SaveImageToStream(thumbnail);
                            var thumbnailBlob   = _thumbnailContainer.GetBlockBlobReference(file.RowKey);
                            thumbnailBlob.UploadFromStream(thumbnailStream);
                            thumbnailStream.Close();
                            thumbnailStream.Dispose();

                            file.ThumbnailUrl = thumbnailBlob.Uri.ToString();
                            _ctx.UpdateObject(file);
                            _ctx.SaveChangesWithRetries();
                        }
                        catch { continue; }
                    }
                }
                else
                {
                    break;
                }
            }
        }
Exemple #10
0
        public void InitializeHostedServiceStatus(string serviceRegion, string serviceUrlPrefix)
        {
            try
            {
                CloudStorageAccount account      = CloudStorageAccount.FromConfigurationSetting("DataConnectionString");
                CloudTableClient    tableStorage = account.CreateCloudTableClient();
                TableServiceContext context      = tableStorage.GetDataServiceContext();

                tableStorage.CreateTableIfNotExist(ServiceStatusTableName);

                CloudServiceStatus status = context.CreateQuery <CloudServiceStatus>(ServiceStatusTableName)
                                            .Where(p => p.RowKey == serviceUrlPrefix)
                                            .AsTableServiceQuery()
                                            .SingleOrDefault();

                if (status == null)
                {
                    status = new CloudServiceStatus()
                    {
                        PartitionKey = string.Empty,
                        RowKey       = serviceUrlPrefix,
                        Region       = serviceRegion,
                        IsOnline     = true
                    };

                    context.AddObject(ServiceStatusTableName, status);
                }
                else
                {
                    status.Region   = serviceRegion;
                    status.IsOnline = true;
                    context.UpdateObject(status);
                }

                context.SaveChangesWithRetries();
            }
            catch (StorageClientException)
            {
                // A StorageClientException that returns the error message "Unexpected internal storage client error" may be retried. Other
                // errors are due to incorrect request parameters and should not be retried with the same parameters.
                // DiagnosticUtility.Trace.LogException(scex, "Error initializing storage due to a client-side error.");
            }
            catch (StorageServerException)
            {
                // These may be transient and requests resulting in such exceptions can be retried with the same parameters.
                // DiagnosticUtility.Trace.LogException(ssex, "Error initializing storage due to a server-side error.");
            }
        }
        protected void DelAllBut_Click(object sender, EventArgs e)
        {
#if AZURE
            var storageAccount = CloudStorageAccount.Parse(Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironment.GetConfigurationSettingValue("fiftyonedegrees"));
            var serviceContext = new TableServiceContext(storageAccount.TableEndpoint.ToString(), storageAccount.Credentials);
            storageAccount.CreateCloudTableClient().CreateTableIfNotExist("log");

            foreach (var row in serviceContext.CreateQuery <LogMessageEntity>("log"))
            {
                serviceContext.DeleteObject(row);
            }
            serviceContext.SaveChanges();

            Page.Response.Redirect(Page.Request.Url.ToString(), true);
#endif
        }
        public IEnumerable <FileEntity> GetFilesMetadata(IEnumerable <string> rowKeys)
        {
            // TODO: Exercise 2: Task 2b: Get the table context and then use it
            // to query the table for each row key. Use yield return to
            // return each file entity you find in the table

            TableServiceContext tableContext = GetTableContext();

            foreach (var rowKey in rowKeys)
            {
                var fileEntity = (from file in tableContext.CreateQuery <FileEntity>(MetadataTable)
                                  where file.RowKey == rowKey
                                  select file).Single();

                yield return(fileEntity);
            }
        }
        protected void Load_Data()
        {
#if AZURE
            //Access the storage account
            var storageAccount = CloudStorageAccount.Parse(RoleEnvironment.GetConfigurationSettingValue("fiftyonedegrees"));
            //Create the service context to access the table
            var serviceContext = new TableServiceContext(storageAccount.TableEndpoint.ToString(), storageAccount.Credentials);

            //Getting the table entries
            foreach (var row in serviceContext.CreateQuery <LogMessageEntity>("log"))    //"log" - the name of the table you wish to see
            {
                OutBox.Text += row.Message;
            }
#else
            OutBox.Text = "This page will only work when compiled for use with Windows Azure";
#endif
        }
Exemple #14
0
        public List <Poza> GetPoze()
        {
            var poze  = new List <Poza>();
            var query = (from file in _ctx.CreateQuery <FileEntity>(_filesTable.Name)
                         select file).AsTableServiceQuery <FileEntity>(_ctx);

            foreach (var file in query)
            {
                poze.Add(new Poza()
                {
                    Description  = file.RowKey,
                    ThumbnailUrl = file.ThumbnailUrl,
                    Url          = file.Url
                });
            }

            return(poze);
        }
Exemple #15
0
        public ApiKeyEntity RetrieveApiKey(string apiKey)
        {
            CloudTableClient tableClient = _storageAccount.CreateCloudTableClient();

            // Get the data service context
            TableServiceContext serviceContext = tableClient.GetDataServiceContext();

            CloudTableQuery <ApiKeyEntity> partitionQuery = (from e in serviceContext.CreateQuery <ApiKeyEntity>("keys")
                                                             where e.PartitionKey == apiKey
                                                             select e).AsTableServiceQuery <ApiKeyEntity>();

            foreach (ApiKeyEntity apiKeyEntity in partitionQuery)
            {
                return(apiKeyEntity);
            }

            return(null);
        }
Exemple #16
0
        public override string[] GetRolesForUser(string username)
        {
            SecUtility.CheckParameter(ref username, true, false, true, Constants.MaxTableUsernameLength, "username");
            if (username.Length < 1)
            {
                return(new string[0]);
            }

            try
            {
                TableServiceContext        svc      = CreateDataServiceContext();
                DataServiceQuery <RoleRow> queryObj = svc.CreateQuery <RoleRow>(_tableName);

                var query = (from user in queryObj
                             where user.PartitionKey == SecUtility.CombineToKey(_applicationName, username) ||
                             user.PartitionKey == SecUtility.CombineToKey(_applicationName, string.Empty)
                             select user).AsTableServiceQuery();

                IEnumerable <RoleRow> userRows = query.Execute();

                if (userRows == null)
                {
                    return(new string[0]);
                }
                List <RoleRow> l = new List <RoleRow>(userRows);
                if (l.Count == 0)
                {
                    return(new string[0]);
                }
                List <string> ret = new List <string>();
                foreach (RoleRow user in l)
                {
                    if (!string.IsNullOrEmpty(user.UserName) && !IsStaleRole(l, user.RoleName))
                    {
                        ret.Add(user.RoleName);
                    }
                }
                return(ret.ToArray());
            }
            catch (InvalidOperationException e)
            {
                throw new ProviderException("Error while accessing the data store.", e);
            }
        }
Exemple #17
0
        private void InitColumnNames()
        {
            if (_columnNames == null)
            {
                TableServiceContext ctx = _tableClient.GetDataServiceContext();
                ctx.IgnoreMissingProperties = true;
                ctx.ReadingEntity          += GenericTableReader.OnReadingEntity;

                var           x   = from o in ctx.CreateQuery <GenericEntity>(_tableName) select o;
                GenericEntity all = x.First();

                List <string> props = new List <string>();
                props.Add("PartitionKey");
                props.Add("RowKey");

                props.AddRange(all.properties.Keys);

                _columnNames = props.ToArray();
            }
        }
Exemple #18
0
        public static Dictionary <string, RoutingInfo> GetConfigDictionary()
        {
            Dictionary <string, RoutingInfo> config = (Dictionary <string, RoutingInfo>)_configCache.Get(_partitionKey);

            if (config == null)
            {
                new Dictionary <string, RoutingInfo>();
                TableServiceContext           tableContext = GetTableContext();
                CloudTableQuery <RouteEntity> routeQuery   =
                    (from e in tableContext.CreateQuery <RouteEntity>(_tableName)
                     where e.PartitionKey == _partitionKey
                     select e)
                    .AsTableServiceQuery <RouteEntity>();
                IEnumerable <RouteEntity> re = routeQuery.Execute();
                config = re.ToDictionary(r => r.RowKey, v => v.GetRoutingInfo());
                _configCache.Remove(_partitionKey);
                _configCache.Add(_partitionKey, config, DateTimeOffset.Now.AddMinutes(_expireMinutes));
            }
            return(config);
        }
Exemple #19
0
        public override string[] GetUsersInRole(string roleName)
        {
            SecUtility.CheckParameter(ref roleName, true, true, true, MaxTableRoleNameLength, "rolename");

            try
            {
                TableServiceContext        svc      = CreateDataServiceContext();
                DataServiceQuery <RoleRow> queryObj = svc.CreateQuery <RoleRow>(_tableName);

                var query = (from user in queryObj
                             where user.PartitionKey.CompareTo(SecUtility.EscapedFirst(_applicationName)) >= 0 &&
                             user.PartitionKey.CompareTo(SecUtility.NextComparisonString(SecUtility.EscapedFirst(_applicationName))) < 0 &&
                             user.RowKey == SecUtility.Escape(roleName)
                             select user).AsTableServiceQuery();
                IEnumerable <RoleRow> userRows = query.Execute();

                if (userRows == null)
                {
                    // role does not exist; we are supposed to throw an exception here
                    throw new ProviderException(string.Format(CultureInfo.InstalledUICulture, "The role {0} does not exist!", roleName));
                }
                List <RoleRow> l = new List <RoleRow>(userRows);
                if (l.Count == 0 || IsStaleRole(l, roleName))
                {
                    throw new ProviderException(string.Format(CultureInfo.InstalledUICulture, "The role {0} does not exist!", roleName));
                }
                List <string> ret = new List <string>();
                foreach (RoleRow user in l)
                {
                    if (!string.IsNullOrEmpty(user.UserName))
                    {
                        ret.Add(user.UserName);
                    }
                }
                return(ret.ToArray());
            }
            catch (InvalidOperationException e)
            {
                throw new ProviderException("Error while accessing the data store.", e);
            }
        }
Exemple #20
0
        public static T Lookup <T>(CloudTableClient tableClient, string tableName, string partitionKey, string rowKey) where T : TableServiceEntity
        {
            TableServiceContext ctx = tableClient.GetDataServiceContext();

            // Azure will special case this lookup pattern for a single entity.
            // See http://blogs.msdn.com/b/windowsazurestorage/archive/2010/11/06/how-to-get-most-out-of-windows-azure-tables.aspx
            try
            {
                // This will throw DataServiceQueryException if not found. (as opposed to return an empty query)
                var x = from row in ctx.CreateQuery <T>(tableName)
                        where row.PartitionKey == partitionKey && row.RowKey == rowKey
                        select row;
                var x2 = x.AsTableServiceQuery <T>();

                return(x2.First());
            }
            catch (DataServiceQueryException)
            {
                // Not found.
                return(null);
            }
        }
        // Merge update an entity (preserve previous properties not overwritten).
        // Return true on success, false if not found, throw exception on error.

        public bool MergeUpdateEntity <T>(string tableName, string partitionKey, string rowKey, T obj) where T : TableServiceEntity
        {
            try
            {
                TableServiceContext tableServiceContext = TableClient.GetDataServiceContext();
                IQueryable <T>      entities            = (from e in tableServiceContext.CreateQuery <T>(tableName)
                                                           where e.PartitionKey == partitionKey && e.RowKey == rowKey
                                                           select e);

                T entity = entities.FirstOrDefault();

                Type           t  = obj.GetType();
                PropertyInfo[] pi = t.GetProperties();

                foreach (PropertyInfo p in pi)
                {
                    p.SetValue(entity, p.GetValue(obj, null), null);
                }

                tableServiceContext.UpdateObject(entity);
                tableServiceContext.SaveChanges();

                return(true);
            }
            catch (DataServiceRequestException)
            {
                return(false);
            }
            catch (StorageClientException ex)
            {
                if ((int)ex.StatusCode == 404)
                {
                    return(false);
                }

                throw;
            }
        }
        public IQueryable <T> GetAllByPartitionKey <T>(string tableName, string partitionKey) where T : TableServiceEntity
        {
            try
            {
                TableServiceContext tableServiceContext = TableClient.GetDataServiceContext();
                return(from e in tableServiceContext.CreateQuery <T>(tableName)
                       where e.PartitionKey == partitionKey
                       select e);
            }
            catch (DataServiceRequestException)
            {
            }
            catch (StorageClientException ex)
            {
                if ((int)ex.StatusCode == 404)
                {
                }

                throw;
            }

            return(null);
        }
        /// <summary>
        /// Returns the entity if present from the table service. Should only be called after
        /// checking the entity is not already present in the context.
        /// </summary>
        /// <param name="record">Request record of the entity being sought.</param>
        /// <returns>The entity if present in the table service.</returns>
        private RequestEntity GetEntityFromTable(RequestRecord record)
        {
            // Create query to return all matching entities for this record.
            CloudTableQuery <RequestEntity> query = (from entity
                                                     in _serviceContext.CreateQuery <RequestEntity>(_tableName)
                                                     where entity.PartitionKey == record.PartitionKey && entity.RowKey == record.RowKey
                                                     select entity).AsTableServiceQuery <RequestEntity>();

            // Return the first or default entity found.
            try
            {
                return(query.Execute().FirstOrDefault());
            }
            catch (DataServiceQueryException ex)
            {
                //If an exception occurs checked for a 404 error code meaning the resource was not found.
                if (ex.Response.StatusCode == 404)
                {
                    return(null);
                }
                throw ex;
            }
        }
Exemple #24
0
        public override bool RoleExists(string roleName)
        {
            SecUtility.CheckParameter(ref roleName, true, true, true, MaxTableRoleNameLength, "rolename");
            try
            {
                TableServiceContext        svc      = CreateDataServiceContext();
                DataServiceQuery <RoleRow> queryObj = svc.CreateQuery <RoleRow>(_tableName);

                var query = (from role in queryObj
                             where role.PartitionKey == SecUtility.CombineToKey(_applicationName, string.Empty) &&
                             role.RowKey == SecUtility.Escape(roleName)
                             select role).AsTableServiceQuery();

                try
                {
                    // this query addresses exactly one result
                    // we thus should get an exception if there is no element
                    return(query.Execute().Any());
                }
                catch (InvalidOperationException e)
                {
                    if ((e.InnerException is DataServiceClientException && (e.InnerException as DataServiceClientException).StatusCode == (int)HttpStatusCode.NotFound) ||
                        (e.InnerException.InnerException is DataServiceClientException && (e.InnerException.InnerException as DataServiceClientException).StatusCode == (int)HttpStatusCode.NotFound))
                    {
                        return(false);
                    }
                    else
                    {
                        throw;
                    }
                }
            }
            catch (InvalidOperationException e)
            {
                throw new ProviderException("Error while accessing the data store.", e);
            }
        }
Exemple #25
0
        private UserEntity GetUserEntity(string wiki, string username)
        {
            if (_users == null)
            {
                _users = new Dictionary <string, UserEntity>();
            }

            if (!_users.ContainsKey(username))
            {
                var userQuery = (from e in _context.CreateQuery <UserEntity>(UsersTable).AsTableServiceQuery()
                                 where e.PartitionKey.Equals(wiki) && e.RowKey.Equals(username)
                                 select e).AsTableServiceQuery();
                var entity = QueryHelper <UserEntity> .FirstOrDefault(userQuery);

                if (entity == null)
                {
                    return(null);
                }
                _users[username] = entity;
            }
            return(_users[username]);
        }
        // Delete entity.
        // Return true on success, false if not found, throw exception on error.

        public bool DeleteEntity <T>(string tableName, string partitionKey, string rowKey) where T : TableServiceEntity
        {
            try
            {
                TableServiceContext tableServiceContext = TableClient.GetDataServiceContext();
                IQueryable <T>      entities            = (from e in tableServiceContext.CreateQuery <T>(tableName)
                                                           where e.PartitionKey == partitionKey && e.RowKey == rowKey
                                                           select e);

                T entity = entities.FirstOrDefault();

                if (entities != null)
                {
                    tableServiceContext.DeleteObject(entity);
                    tableServiceContext.SaveChanges();
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (DataServiceRequestException)
            {
                return(false);
            }
            catch (StorageClientException ex)
            {
                if ((int)ex.StatusCode == 404)
                {
                    return(false);
                }

                throw;
            }
        }
Exemple #27
0
 // Get contact using existing context.
 public static ContactEntity GetContact(string rowKey, TableServiceContext context)
 {
     return(context.CreateQuery <ContactEntity>(tableName).Where(e => e.PartitionKey == rowKey.Substring(0, 1).ToUpper() && e.RowKey == rowKey).Single());
 }
Exemple #28
0
        public List <string> GetUrls()
        {
            var r = _tableContext.CreateQuery <StoredSiteUrl>(_tableName);

            return(r.ToList().Select(x => x.Url).ToList());
        }
Exemple #29
0
 public static IEnumerable <Person> Get(TableServiceContext context)
 {
     return(from e in context.CreateQuery <Person>("Entities")
            where e.PartitionKey == "0"
            select e);
 }
        /// <summary>
        /// Read data entries and their corresponding eTags from the Azure table.
        /// </summary>
        /// <param name="predicate">Predicate function to use for querying the table and filtering the results.</param>
        /// <returns>Enumeration of entries in the table which match the query condition.</returns>
        internal async Task <IEnumerable <Tuple <T, string> > > ReadTableEntriesAndEtagsAsync(Expression <Func <T, bool> > predicate)
        {
            const string operation = "ReadTableEntriesAndEtags";
            var          startTime = DateTime.UtcNow;

            try
            {
                TableServiceContext svc = tableOperationsClient.GetDataServiceContext();
                // Improve performance when table name differs from class name
                // http://www.gtrifonov.com/2011/06/15/improving-performance-for-windows-azure-tables/
                svc.ResolveType = ResolveEntityType;

                //IQueryable<T> query = svc.CreateQuery<T>(TableName).Where(predicate);
                CloudTableQuery <T> cloudTableQuery = svc.CreateQuery <T>(TableName).Where(predicate).AsTableServiceQuery(); // turn IQueryable into CloudTableQuery

                try
                {
                    Func <Task <List <T> > > executeQueryHandleContinuations = async() =>
                    {
                        // Read table with continuation token
                        // http://convective.wordpress.com/2013/11/03/queries-in-the-windows-azure-storage-client-library-v2-1/

                        // 1) First wrong sync way to read:
                        // List<T> queryResults = query.ToList(); // ToList will actually execute the query and add entities to svc. However, this will not handle continuation tokens.
                        // 2) Second correct sync way to read:
                        // http://convective.wordpress.com/2010/02/06/queries-in-azure-tables/
                        // CloudTableQuery.Execute will properly retrieve all the records from a table through the automatic handling of continuation tokens:
                        Task <ResultSegment <T> > firstSegmentPromise = Task <ResultSegment <T> > .Factory.FromAsync(
                            cloudTableQuery.BeginExecuteSegmented,
                            cloudTableQuery.EndExecuteSegmented,
                            null);

                        // 3) Third wrong async way to read:
                        // return firstSegmentPromise;
                        // 4) Forth correct async way to read - handles continuation tokens:

                        var list = new List <T>();

                        Task <ResultSegment <T> > nextSegmentAsync = firstSegmentPromise;
                        while (true)
                        {
                            ResultSegment <T> resultSegment = await nextSegmentAsync;
                            var capture = resultSegment.Results;
                            if (capture != null) // don't call Count or Any or anything else that can potentialy cause multiple evaluations of the IEnumerable
                            {
                                list.AddRange(capture);
                            }

                            if (!resultSegment.HasMoreResults)
                            {
                                // All data was read successfully if we got to here
                                break;
                            }

                            // ask to read the next segment
                            nextSegmentAsync = Task <ResultSegment <T> > .Factory.FromAsync(
                                resultSegment.BeginGetNext,
                                resultSegment.EndGetNext,
                                null);
                        }

                        return(list);
                    };

                    IBackoffProvider backoff = new FixedBackoff(AzureTableDefaultPolicies.PauseBetweenTableOperationRetries);

                    List <T> results = await AsyncExecutorWithRetries.ExecuteWithRetries(
                        counter => executeQueryHandleContinuations(),
                        AzureTableDefaultPolicies.MaxTableOperationRetries,
                        (exc, counter) => AzureStorageUtils.AnalyzeReadException(exc.GetBaseException(), counter, TableName, Logger),
                        AzureTableDefaultPolicies.TableOperationTimeout,
                        backoff);

                    // Data was read successfully if we got to here
                    return(PairEntitiesWithEtags(svc, results));
                }
                catch (Exception exc)
                {
                    // Out of retries...
                    var errorMsg = string.Format("Failed to read Azure storage table {0}: {1}", TableName, exc.Message);
                    if (!AzureStorageUtils.TableStorageDataNotFound(exc))
                    {
                        Logger.Warn(ErrorCode.AzureTable_09, errorMsg, exc);
                    }
                    throw new OrleansException(errorMsg, exc);
                }
            }
            finally
            {
                CheckAlertSlowAccess(startTime, operation);
            }
        }