Private voidaccountinfo () {ls. Clear (); DateTime DT=DateTime.Now.Date; Imongoquery Query= Query<mtime_time>. GTE (p =p.showdate, DT); Mapreduceoutput Output=NewMapreduceoutput ("Mtime_time_tem"); Mongocollection Comcol= Mongofactory.getmongocollction ("Entboxoffice","Mtime_time_tem"); stringMapjs =@"function () {var result = {}; Total session var count = 0; Someone played var haspersoncount = 0; Storage session var Hasin = 0; Total number of inbound var inpersoncount = 0; Total number of var personcount = 0; Count = 1; if (This.sold > 0) {haspersoncount = 1; Personcount = This.sold; if (this. Sqlsta = = 1) {inpersoncount = This.sold; }} if (this. Sqlsta = = 1) {hasin = 1; } Result.count = count; Result.haspersoncount = Haspersoncount; Result.hasin = Hasin; Result.inpersoncount = Inpersoncount; Result.personcount = Personcount;emit (This.movieid, result); }"; stringReducejs =@"function (key, values) {var result = {}; Result.count = 0; Result.haspersoncount = 0; Result.hasin = 0; Result.inpersoncount = 0; Result.personcount = 0; Values.foreach (function (value) {result.count + = Value.count; Result.haspersoncount + = Value.haspersoncount; Result.hasin + = Value.hasin; Result.inpersoncount + = Value.inpersoncount; Result.personcount + = Value.personcount; }); return result;}"; Try { varOptions =NewMapreduceoptionsbuilder (). Setquery (query). Setoutput (output); varMap =NewBsonjavascript (MAPJS); varreduce =NewBsonjavascript (Reducejs); varobj =mtime_timeDAL.collection.MapReduce (map, reduce, options); List<BsonDocument> doc =obj. GetResults (). ToList (); //list<moveibase>//Jinyi_timedal.collectionmovieGetdocaddls (Doc,"Time Net"); Comcol. Drop (); Map=NewBsonjavascript (Mapjs. Replace ("MovieID","Filmid")); Obj=wd_timeDAL.collection.MapReduce (map, reduce, options); Doc=obj. GetResults (). ToList (); } Catch(Exception ex) {Throw; } }
MongoDB map/reduce Test Code