internal async Task <IEnumerable <Document> > GetDocumentsAsync <T>(List <KeyValuePair <string, object> > filterNameValues, string partitionKey, CancellationToken cancellationToken, bool appendSystemDataFilter = true)
        {
            EnsureArg.IsNotNull(partitionKey, nameof(partitionKey));

            var queryBuilder          = new StringBuilder();
            var queryParameterManager = new QueryParameterManager();

            var queryHelper = new QueryHelper(queryBuilder, queryParameterManager, "r");

            queryHelper.AppendSelectFromRoot("r");

            string filterCondition = "WHERE";

            if (appendSystemDataFilter)
            {
                queryHelper.AppendSystemDataFilter(true);
                filterCondition = "AND";
            }

            if (filterNameValues != null)
            {
                queryHelper.AppendFilterCondition(filterCondition, filterNameValues.Select(kvp => (kvp.Key, kvp.Value)).ToArray());
            }

            var documentQuery = new SqlQuerySpec(
                queryBuilder.ToString(),
                queryParameterManager.ToSqlParameterCollection());

            var feedOptions = new FeedOptions
            {
                PartitionKey = new PartitionKey(partitionKey),
            };

            IDocumentQuery <T> cosmosDocumentQuery =
                CreateDocumentQuery <T>(documentQuery, feedOptions);

            using (cosmosDocumentQuery)
            {
                var retDocuments = new List <Document>();
                while (cosmosDocumentQuery.HasMoreResults)
                {
                    retDocuments.AddRange(await cosmosDocumentQuery.ExecuteNextAsync <Document>(cancellationToken));
                }

                return(retDocuments);
            }
        }