查询具有两个具有相同名称的属性的Azure DocumentDB

时间:2017-09-25 17:03:54

标签: c# azure azure-cosmosdb

我正在尝试通过以下属性

查询DocumentDB
 "Loop": [
    {
      "@LoopId": "0204",
      "@Name": "Order Information Detail",
      "OID": {
        "OID01": null,
        "OID02": "1NN***"
      }
    },
    {
      "@LoopId": "0210",
      "@Name": "Quantity Information",
      "QTY": {
        "#comment": [],
        "QTY01": {
          "#text": "H9"
        },
        "QTY02": "10",
        "QTY03": null,
        "QTY04": "Pallets"
      }]

使用查询

SELECT * FROM c WHERE c.Loop [0] .OID.OID02 =“1NN ***”;

但是同一个文档中还有另一个属性Loop:

 "Loop": [
{
  "@LoopId": "0100",
  "@Name": "Party Identification",
  "N1": {
    "#comment": [],
    "N101": {
      "#text": "CA"
    },
    "N102": "BN*********",
    "N103": {
      "#text": "2"
    },
    "N104": "B***"
  }
},
{
  "@LoopId": "0100",
  "@Name": "Party Identification",
  "N1": {
    "#comment": [],
    "N101": {
      "#text": "SF"
    },
    "N102": "*****"
  }]

无论如何都是因为我需要通过OID获取信息 提前谢谢

1 个答案:

答案 0 :(得分:0)

你能尝试这个查询,因为我认为每个" row"在Loop数组中是一个不同的Loop对象:

SELECT * FROM Loop c WHERE c.OID.OID02 = "1NN***";