我已经获得了所有产品的api。但是它像打击一样返回。请纠正我,我怎么了?
我的存储库代码:
public async Task<IEnumerable<Product>> FetchProductListAsync(
Guid? itemId)
{
var feedOptions =
new FeedOptions
{
MaxItemCount = -1,
EnableCrossPartitionQuery = true
};
var query =
$"SELECT product FROM catalog join industry in catalog.Industy join category in industry.Category join product in category.Subcategory.Product where catalog.id ='" + itemId + "'";
var queryDefinition =
new SqlQuerySpec(query);
var orderDocumentQuery =
_cosmosClient.CreateDocumentQuery<Product>(
UriFactory.CreateDocumentCollectionUri(
_azureCosmosDbOptions.Value.DatabaseId, "catalog"), queryDefinition, feedOptions)
.AsDocumentQuery();
var childrenSqlQuery = _cosmosClient.CreateDocumentQuery(UriFactory.CreateDocumentCollectionUri(_azureCosmosDbOptions.Value.DatabaseId, "catalog"), query).AsDocumentQuery();
var result = await childrenSqlQuery.ExecuteNextAsync();
if (result.Any())
{
if (result.FirstOrDefault() != null)
{
var countObj = result.FirstOrDefault();
}
}
var orderList =
new List<Product>();
while (orderDocumentQuery.HasMoreResults)
{
orderList.AddRange(
await orderDocumentQuery.ExecuteNextAsync<Product>());
Console.WriteLine(orderList);
}
return orderList;
}
实际输入返回插件和准备方法为null。 实际输出:
[
{
"Id": "12a22f6a-c75a-4622-b2ae-819714737147",
"hasMethodOfPreparation": false,
"methodOfPreparation": null,
"addons": null
}
]
但是我需要完整的阵列才能像打击一样返回 预期输出:
[
{
"Id": "d8ca2be8-845e-4f3b-854a-fdd10653a2ce",
"MethodOfPreparation": [
{
"id": "6eac1ea7-0d71-4181-a7b5-8a034b1922c3",
}
],
"Addons": [
{
"id": "72902f16-2a39-44bc-987b-4e17fc0756fc"
}
]
}
]
如何解决此问题。例如,我需要获取所有产品的目录ID。