将此代码转换为.NET
时遇到一些麻烦。它位于两个[
]
db.account.aggregate([ { $group: { _id : null, total: {$sum: 1}, "Pricebook ID": {$addToSet: "$Pricebook ID"}, }, },{ $project: { "Pricebook ID": { $eq: [ "$total", {$size: "$Pricebook ID"} ] } } } ]);
目前,这是.NET
中的代码。谁知道最后一部分?
Dim Aggregate = Collection.Aggregate.
Group(
New BsonDocument From
{
{"_id", BsonNull.Value},
{"total", New BsonDocument From
{
{"$sum", 1}
}
},
{"Pricebook ID", New BsonDocument From
{
{"$addToSet", "$Pricebook ID"}
}
}
}
).
Project(
New BsonDocument From
{
{"Pricebook ID", New BsonDocument From
{
{"Pricebook ID", New BsonDocument From
{
{"$eq", <code here>}
}
}
}
}
}
)
谢谢!
答案 0 :(得分:0)
由于这一点,我能够弄清楚自己:MongoDB Aggregation Pipeline C#
答案:
Dim Aggregate = Collection.Aggregate.
Group(New BsonDocument From {
{"_id", BsonNull.Value},
{"total", New BsonDocument From {
{"$sum", 1}}},
{"Pricebook ID", New BsonDocument From {
{"$addToSet", "$Pricebook ID"}}}}
).
Project(
New BsonDocument From {
{"Pricebook ID", New BsonDocument From {
{"$eq", New BsonArray From {
"$total", New BsonDocument From {
{"$size", "$Pricebook ID"}}}}}}}
)