我正在尝试下面的代码来获取详细信息,但它没有返回我想要的。
我的查询:
var query = $"SELECT catalog.id as vendorguid,catalog.VendorName,industry.Id as industryguid,industry.IdustryId,industry.IdustryName,category.id as categoryguid,category.Name as categoryname,category.Description as categorydescription,Subcategory.Id as subcategoryguid,Subcategory.Name as subcategoryname,Subcategory.Description as subcategorydescription,product.Id as productguid,product.Name as productname,product.CurrentQuantity as productCurrentQuantity,product.Tag as productTag,product.ImageUrl as productImageUrl,product.Unit as productUnit,product.Price as productPrice,product.hasMethodOfPreparation as producthasMethodOfPreparation,product.MethodOfPreparation as productMethodOfPreparation,product.Addons as productAddons FROM catalogjoin industry in catalog.Industy join category in industry.Category join Subcategory in category.Subcategoryjoin product in Subcategory.Product where product.Id = '"+productId+"'";
输出:
{
"id": "d91af3e6-6aae-4d10-9ba6-6b97ca4cd881",
"vendorName": "string",
"industy": []
}
预期输出:
{
"vendorguid": "97392a23-c8c4-4a7f-bffb-7c3807cc40de",
"VendorName": "string",
"industryguid": "f8265ee6-a351-4036-a0ee-10ec4f51ecf4",
"IdustryId": 0,
"IdustryName": "string",
"categoryguid": "ce7edfdf-1608-4a8c-ae38-7ca60c43bc30",
"categoryname": "string",
"categorydescription": "string",
"subcategoryguid": "709f4e6f-1bba-421f-8dc0-7cf067cbc032",
"subcategoryname": "string",
"subcategorydescription": "string",
"productguid": "d24dd340-d7a2-42e5-b84a-1ee72d9840c6",
"productname": "string",
"productCurrentQuantity": 0,
"productTag": "string",
"productImageUrl": [
"string"
],
"productUnit": 0,
"productPrice": 0,
"producthasMethodOfPreparation": true,
"productMethodOfPreparation": [
],
"productAddons": [
]
}
答案 0 :(得分:0)
我认为问题出在您的联接中(类别,子类别)。您确定它总是找到匹配的吗?如果没有找不到匹配项或没有该属性,则CosmosDb将不将其包括在结果集中。
这不像MSSQL的左联接中包含空值。 CosmosDb更像是完全外部联接(交叉联接)。