Reputation: 4371
I have 2 objects in DocumentDB like below,
{
"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",
}
}
I want to get the document where a Codes with trackcode='191155772333RIF1'.
I tried the following query and it is not returning the document from 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 }
}));
Can any one help me to get the document from DocDB.
Thanks
Upvotes: 0
Views: 82
Reputation: 15603
I tried with this query and it seemed to work correctly:
select doc.TrackGoods from doc join Codes in doc.TrackGoods.Codes where Codes.trackcode = '191155772333RIF1'
You were missing the .TrackGoods.
in after the in
.
For more information regarding JOIN
, take a look at this article.
Upvotes: 1