public async Task <SegmentedResult <TItem> > GetAllAsync <TItem>(string continuationToken = null, string partitionKey = null, string rowKey = null, int rowCount = 500) where TItem : class, ITableItem, new()
        {
            string partitionQuery = null, rowQuery = null;

            TableQuery query = new TableQuery();

            if (!string.IsNullOrWhiteSpace(partitionKey))
            {
                partitionQuery = TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.Equal, partitionKey);
            }
            if (!string.IsNullOrWhiteSpace(rowKey))
            {
                rowQuery = TableQuery.GenerateFilterCondition("RowKey", QueryComparisons.Equal, rowKey);
            }

            if (null != partitionQuery)
            {
                query = query.Where(partitionQuery);
            }
            if (null != rowQuery)
            {
                query = query.Where(rowQuery);
            }

            query.TakeCount = rowCount;

            var token       = AzureStorageUtilities.DeserializeTableContinuationToken(continuationToken);
            var azureResult = await this.Table.ExecuteQuerySegmentedAsync(query, token);

            IEnumerable <TItem> itemsList = azureResult.Results.Select(x => this.Assembler.Assemble <TItem>((DynamicTableEntity)x));
            string nextPageToken          = azureResult.ContinuationToken.Serialize();

            return(new SegmentedResult <TItem>(itemsList, nextPageToken, null != nextPageToken));
        }
        public async Task <SegmentedResult <TItem> > SelectAsync <TItem>(Expression <Func <TItem, bool> > queryExpression, string continuationToken = null, int rowCount = 500) where TItem : class, ITableItem, new()
        {
            QueryExpressionVisitor <TItem> visitor = new QueryExpressionVisitor <TItem>();

            _ = (Expression <Func <TItem, bool> >)visitor.Visit(queryExpression);

            DataServiceContext context = new DataServiceContext(new Uri("https://tempuri.org"));
            var    dataServiceQuery    = context.CreateQuery <TItem>("/items").Where(queryExpression);
            string queryString         = (((DataServiceQuery)dataServiceQuery).RequestUri).Query;
            var    queryCollection     = HttpUtility.ParseQueryString(queryString);

            TableQuery query = new TableQuery()
            {
                FilterString = queryCollection.Get("$filter"),
                TakeCount    = rowCount,
            };

            this.Logger.LogInformation($"Running Azure table query: {query.FilterString}");

            var token       = AzureStorageUtilities.DeserializeTableContinuationToken(continuationToken);
            var azureResult = await this.Table.ExecuteQuerySegmentedAsync(query, token);

            IEnumerable <TItem> itemsList = azureResult.Results.Select(x => this.Assembler.Assemble <TItem>((DynamicTableEntity)x));
            string nextPageToken          = azureResult.ContinuationToken.Serialize();

            return(new SegmentedResult <TItem>(itemsList, nextPageToken, null != nextPageToken));
        }