Thursday, 15 March 2012

mongodb csharp - New (2.6) $cond Aggregation Framework with c#? -



mongodb csharp - New (2.6) $cond Aggregation Framework with c#? -

i'm going crazy one...

i have aggregation framework look working charm in mongo shell:

{ $group : { _id : '$code' , 'special' : { $sum : { $cond: [{ $eq: [ '$special', 'success']},1,0]}} } }

i need in c#, tried lot of combinations without success.

has clue?

thx

give try:

var grouping = new bsondocument { { "$group", new bsondocument { { "_id", "$code" }, { "special", new bsondocument { { "$sum", new bsondocument { {"$cond", new bsonarray { new bsondocument { { "$eq", new bsonarray {"$special", "success"} } }, 1, 0 } } } } } } } } };

mongodb-csharp

No comments:

Post a Comment