GlobalDemo.DAL.Azure.StorageRepository.GetLatestFromTableStorageAsync C# (CSharp) Method

GetLatestFromTableStorageAsync() public method

This is a full table scan. Yuck.
public GetLatestFromTableStorageAsync ( ) : Task>
return Task>
        public async Task<List<IPhotoModel>> GetLatestFromTableStorageAsync()
        {            
            var client = _account.CreateCloudTableClient();
            var table = client.GetTableReference(StorageConfig.TableName);

            //Scan all partitions looking for entities with a DateAdded property
            //   equal to today.  This is inefficient, and one of the reasons
            //   we introduce Redis as a cache.
            TableQuery<PhotoEntity> tableScanQuery = new TableQuery<PhotoEntity>().Where
                (TableQuery.CombineFilters(
                    TableQuery.GenerateFilterCondition("YearAdded", QueryComparisons.Equal, System.DateTime.Now.Year.ToString()),
                    TableOperators.And,
                    TableQuery.CombineFilters(
                        TableQuery.GenerateFilterCondition("MonthAdded", QueryComparisons.Equal, System.DateTime.Now.Month.ToString()),
                        TableOperators.And,
                        TableQuery.GenerateFilterCondition("DayAdded", QueryComparisons.Equal, System.DateTime.Now.Day.ToString()))));

            TableContinuationToken token = null;
            List<IPhotoModel> ret = new List<IPhotoModel>();
            // Page through the results
            do
            {
                TableQuerySegment<PhotoEntity> segment = await table.ExecuteQuerySegmentedAsync(
                    tableScanQuery,
                    token);
                token = segment.ContinuationToken;
                foreach (PhotoEntity entity in segment)
                {
                    ret.Add(new PhotoModel(entity));
                }
            }
            while (token != null);
            return ret;
        }

Usage Example

        public async Task<IHttpActionResult> Get()
        {
            var cache = RedisCache.Connection.GetDatabase();
            var repo = new RedisRepository(cache);
            var items = await repo.GetAllPhotosAsync();
            
            List<IPhotoModel> typedItems = new List<IPhotoModel>(items);
            if(typedItems.Count == 0)
            {
                //Pull from storage.  This is a cross-partition query,
                //  and will be slower than using Redis.
                var storageConnectionString = SettingsHelper.LocalStorageConnectionString;
                var storageRepo = new StorageRepository(storageConnectionString);
                typedItems = await storageRepo.GetLatestFromTableStorageAsync();
                if(typedItems.Count > 0)
                {
                    foreach (var item in typedItems)
                    {
                        //Add to cache as cache-aside pattern
                        await repo.AddPhotoToAllUsersCacheAsync(item);
                    }
                    items = typedItems;
                }
            }


            return Ok(items);
        }