0
在DocumentDb中,是否可以搜索子文檔以獲取父文檔?如何查詢嵌入式數據documentDB以檢索父文檔
public class Customer
{
[JsonProperty(PropertyName = "id")]
public string Id { get; set; }
[JsonProperty(PropertyName = "name")]
public string Name { get; set; }
[JsonProperty(PropertyName = "locations")]
public List<Location> Locations { get; set; }
public Customer()
{
Locations = new List<Location>();
}
}
public class Location
{
[JsonProperty(PropertyName = "id")]
public string Id { get; set; }
[JsonProperty(PropertyName = "city")]
public string City{ get; set; }
[JsonProperty(PropertyName = "state")]
public string State{ get; set; }
}
在文檔資源管理器,我可以看到我有這個階級結構的一個實例,像這樣:
{
"id": "7",
"name": "ACME Corp",
"location": [
{
"id": "c4202793-da55-4324-88c9-b9c9fe8f4b6c",
"city": "newcity",
"state": "ca"
}
]
},
{
"id": "35",
"name": "Another Corp",
"location": [
{
"id": "d33e793-da55-4324-88c9-b9c9fe8f4baa",
"city": "newcity",
"state": "ca"
}
]
}
有沒有一種方法來查詢等,其中城市=「newcity」嵌入數據和狀態=「ca」 但檢索父數據?如果我使用SelectMany(x => x.Locations)查詢子項,那麼它將獲取位置數據而不是根(客戶)文檔。
感謝
哇,感謝您的代碼,甚至截屏! – wil