我在DocumentDB中有2个对象,如下所示,
{
"TrackGoods": {
"Attributes": {
"Attribute": {
"BlockName": "Default",
"Brand": "Default",
"CaseType": "Carton",
}
},
"Codes": [{
"trackcode": "191155772333RIF1"
},
{
"trackcode": "721141315199RIF2"
}],
"Time": "2017-12-18T13:35:04.0792480+05:30",
"IpAddress": "127.0.0.1",
"Lat": "155.00",
"Long": "-202.00",
}
}
{
"TrackGoods": {
"Attributes": {
"Attribute": {
"BlockName": "Default1",
"Brand": "Default1",
"CaseType": "Carton1",
}
},
"Codes": [{
"trackcode": "191155772333RIF3"
},
{
"trackcode": "721141315199RIF4"
}],
"Time": "2017-12-18T13:35:04.0792480+05:30",
"IpAddress": "127.0.0.1",
"Lat": "155.00",
"Long": "-202.00",
}
}
我想获取带有trackcode ='191155772333RIF1'的代码的文档。
我尝试了以下查询,它没有从DocDB返回文档,
string selectdoc = "select doc.TrackGoods from doc join Codes in doc.Codes where Codes.trackcode = '191155772333RIF1'";
query = new SqlQuerySpec(selectdoc,
new SqlParameterCollection(new SqlParameter[] {
new SqlParameter { Name = "@code", Value = code }
}));
任何人都可以帮我从DocDB获取文档。
谢谢
我试过这个查询,它似乎工作正常:
select doc.TrackGoods from doc join Codes in doc.TrackGoods.Codes where Codes.trackcode = '191155772333RIF1'
在.TrackGoods.
之后你错过了in
。
有关JOIN
的更多信息,请查看this article。