/// <inheritdoc />
        async Task <EntityQueryResult> IDurableEntityClient.ListEntitiesAsync(EntityQuery query, CancellationToken cancellationToken)
        {
            var condition    = new OrchestrationStatusQueryCondition(query);
            var result       = await((IDurableClient)this).ListInstancesAsync(condition, cancellationToken);
            var entityResult = new EntityQueryResult(result);

            return(entityResult);
        }
        private async Task <HttpResponseMessage> HandleListEntitiesRequestAsync(
            HttpRequestMessage request, string entityName)
        {
            IDurableEntityClient client = this.GetClient(request);
            NameValueCollection  queryNameValuePairs = request.GetQueryNameValuePairs();

            var query = new EntityQuery();

            query.EntityName = entityName;

            if (TryGetDateTimeQueryParameterValue(queryNameValuePairs, LastOperationTimeFrom, out DateTime lastOperationTimeFrom))
            {
                query.LastOperationFrom = lastOperationTimeFrom;
            }

            if (TryGetDateTimeQueryParameterValue(queryNameValuePairs, LastOperationTimeTo, out DateTime lastOperationTimeTo))
            {
                query.LastOperationTo = lastOperationTimeTo;
            }

            if (TryGetIntQueryParameterValue(queryNameValuePairs, PageSizeParameter, out int pageSize))
            {
                query.PageSize = pageSize;
            }

            if (TryGetBooleanQueryParameterValue(queryNameValuePairs, FetchStateParameter, out bool fetchState))
            {
                query.FetchState = fetchState;
            }

            if (request.Headers.TryGetValues("x-ms-continuation-token", out IEnumerable <string> headerValues))
            {
                query.ContinuationToken = headerValues.FirstOrDefault();
            }

            EntityQueryResult result = await client.ListEntitiesAsync(query, CancellationToken.None);

            HttpResponseMessage response = request.CreateResponse(HttpStatusCode.OK, result.Entities);

            response.Headers.Add("x-ms-continuation-token", result.ContinuationToken);
            return(response);
        }