/// <summary> /// Executes the map reduce with any options /// </summary> /// <typeparam retval="X">The return type</typeparam> /// <param retval="options">The options</param> /// <returns></returns> public IEnumerable <X> MapReduce <X>(MapReduceOptions <T> options) { var mr = new MapReduce(_db); var response = mr.Execute(options); var collection = response.GetCollection <X>(); return(collection.Find().ToList()); }
//Helper for using map reduce in mongo public T MapReduce <T>(string map, string reduce) { T result = default(T); MapReduce mr = Db.CreateMapReduce(); MapReduceResponse response = mr.Execute(new MapReduceOptions(typeof(T).Name) { Map = map, Reduce = reduce }); IMongoCollection <MapReduceResult <T> > coll = response.GetCollection <MapReduceResult <T> >(); MapReduceResult <T> r = coll.Find().FirstOrDefault(); result = r.Value; return(result); }