处理FetchListAsync(Nullable <Guid> itemId)时发生未处理的异常

时间:2019-06-04 05:51:52

标签: azure-cosmosdb asp.net-core-webapi

我正在创建一个Web API,以获取特定ID的数据。当我尝试从存储过程表单cosmos db查询运行时,但是从api中返回null。

FetchListAsync方法:

public async Task<IEnumerable<Catalog>> FetchListAsync(
           Guid? itemId)
        {
            var feedOptions =
                  new FeedOptions
                  {
                      MaxItemCount = -1,
                      EnableCrossPartitionQuery = true
                  };

            var query =
                $"SELECT *  FROM catalog f  WHERE f.id =itemId";

            var queryDefinition =
                new SqlQuerySpec(query);

            var orderDocumentQuery =
                _cosmosClient.CreateDocumentQuery<Catalog>(
                    UriFactory.CreateDocumentCollectionUri(
                        _azureCosmosDbOptions.Value.DatabaseId, "catlogdb"), queryDefinition, feedOptions)
                    .AsDocumentQuery();

            var orderList = new List<Catalog>();

            while (orderDocumentQuery.HasMoreResults)
            {
                orderList.AddRange(
                    await orderDocumentQuery.ExecuteNextAsync<Catalog>());
            }

            return orderList;
        }

错误:

我做错了什么?

0 个答案:

没有答案