为什么DocumentDb ExecuteNextAsync挂起?

时间:2019-06-13 14:09:26

标签: asp.net-core azure-cosmosdb

我遇到了异步编程问题。 (类似于此ExecuteNextAsync freezes/hangs in Azure Cosmos DB

它挂在网上:返回结果; 我试着说return results.ToArray();但没有运气

       public async Task<IActionResult> Index()
    {
        var items = await DocumentDBRepository<Plane>.GetItemsAsync(d => d.Active);



        return View(items);
    }



        public static async Task<IEnumerable<T>> GetItemsAsync(Expression<Func<T, bool>> predicate)
    {
        IDocumentQuery<T> query = client.CreateDocumentQuery<T>(
            UriFactory.CreateDocumentCollectionUri(DatabaseId, CollectionId))
            .Where(predicate)
            .AsDocumentQuery();

        List<T> results = new List<T>();
        while (query.HasMoreResults)
        {
            try
            {
                var result = await query.ExecuteNextAsync<T>();
                results.AddRange(result);
            }
            catch (Exception e)
            {

                string s = e.Message;
            }
        }

        //     return results.ToArray();
        return results.ToArray();
    }

0 个答案:

没有答案