我正在创建一个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;
}
我做错了什么?