【发布时间】:2017-04-19 20:18:03
【问题描述】:
我在 c# 中的文档结构:
public class HashTableDocument : Model
{
public int Id { get; set; }
public Dictionary<string, HashSet<int>> items= new Dictionary<string, HashSet<int>>();
}
在蒙古:
{
"_id" : 218,
"items" : {
"1" : [
52711,
201610,
],
"2" : [
246421,
390200
],
"3" : [
105628,
768519
],
"26" : [
17435,
22252,
61389,
65184,
72859,
81421,
931469,
933505,
938377,
959836
],
"27" : [
26917,
38706,
53862,
111816,
827294,
858348,
870334
]
}
}
我希望能够将任何整数列表 ('x') 传递给 Mongo。如果值包含给定列表('x')中的任何整数,则仅对那些键值对进行投影。
例如,在上面的文档中。如果我将 List = { 52711, 105628, 17435, 81421} 传递给 Mongo 那么
它应该返回
{
"_id" : 218,
"items" : {
"1" : [
52711,
201610,
],
"3" : [
105628,
768519
],
"26" : [
17435,
22252,
61389,
65184,
72859,
81421,
931469,
933505,
938377,
959836
],
}
}
因为每个键的值在其列表中都包含至少一个元素。
【问题讨论】:
标签: c# mongodb mongodb-query aggregation-framework projection