开发者

Nested queries in MongoDb using official C# driver

I need to query something like this:

<Parent> 
<Child1> </Child1> 
<Child2> 
<NestedChild1><Key>Weight</Key><Value>80<Value/></NestedChild1> 
<NestedChild2><Key>Age</Key><Value>25<Value/></NestedChild2> 
<NestedChild3><Key>Height</Key><Value>180<Value/></NestedChild3> 
</Child2> 
</Parent> 

I receive the query request in the next form:

NestedChild1==180&&NestedChild2==30 

I tried chaining the queries in such fashion:

 {"Child2.Key" : "Weight",

  "Child2.Value" : "180"  } 

It is obvious 开发者_如何学PythonI receive the wrong results. I think I should search like that:

{"Child2": 

    { 

      "Key": "Weight", 

      "Value": "180" 

 }
} 

But I can't serialize my object using BsonDocument.Create(myObject) What is the best solution to solve my problem and how can I serialize my custom object?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜