示例#1
0
        private void btnFetch_Click(object sender, EventArgs e)
        {
            var c = MongoClient.Instance.DefaultLocalServer["db1"]["t1"];

            var sw = new System.Diagnostics.Stopwatch();

            var          cnt     = 0;
            var          query   = new Query();
            BSONDocument lastDoc = null;

            using (var cursor = c.Find(query))
                foreach (var doc in cursor)
                {
                    cnt++;
                    if (cnt == 1)
                    {
                        sw.Start();
                    }
                    lastDoc = doc;
                    //  if (cnt>3) break;
                }

            var el = sw.ElapsedMilliseconds;

            Text = "Fetched {0} in {1} ms at {2}ops/sec".Args(cnt, el, cnt / (el / 1000d));
            MessageBox.Show(lastDoc.ToString());
        }
示例#2
0
        internal BSONDocument RunCommand(int requestID, Database database, BSONDocument command)
        {
            EnsureObjectNotDisposed();

            m_BufferStream.Position = 0;
            var total = Protocol.Write_RUN_COMMAND(m_BufferStream,
                                                   requestID,
                                                   database,
                                                   command);

            writeSocket(total);

            var got   = readSocket();
            var reply = Protocol.Read_REPLY(got);

            Protocol.CheckReplyDataForErrors(reply);

            if (Protocol.IsOKReplyDoc(reply))
            {
                return(reply.Documents[0]);
            }
            throw new MongoDBConnectorProtocolException(StringConsts.PROTO_RUN_COMMAND_REPLY_ERROR + command.ToString());
        }
示例#3
0
        internal BSONDocument RunCommand(int requestID, Database database, BSONDocument command)
        {
          EnsureObjectNotDisposed();

          m_BufferStream.Position = 0;
          var total = Protocol.Write_RUN_COMMAND(m_BufferStream, 
                                           requestID, 
                                           database, 
                                           command);
          writeSocket(total);
       
          var got = readSocket();
          var reply = Protocol.Read_REPLY(got);
          Protocol.CheckReplyDataForErrors(reply);

           if (Protocol.IsOKReplyDoc(reply))
          {
            return reply.Documents[0];
          }
          throw new MongoDBConnectorProtocolException(StringConsts.PROTO_RUN_COMMAND_REPLY_ERROR + command.ToString()); 
        }