Esempio n. 1
0
        /// <summary>
        /// Executes a command against the database using the provided information
        /// </summary>
        public static CommandResponse RunCommand(MongoDatabase database, BsonObject parameters, bool expectResponse)
        {
            //create the command to use
            CommandRequest request = new CommandRequest(database);
            request.Arguments.Merge(parameters);

            //send the command and check for the result
            CommandResponse response = database.SendRequest(request) as CommandResponse;
            if (response == null && expectResponse) {
                throw new MongoServerException(
                    string.Format(
                        "The request to {0} expected a response but nothing was returned!",
                        database.Connection.Host
                        ));
            }

            //return any documents that were found
            return response;
        }
Esempio n. 2
0
        /// <summary>
        /// Sends the request to kill existing cursors
        /// </summary>
        public static void KillCursors(MongoDatabase database, IEnumerable<long> cursors)
        {
            //give up on an empty cursor count
            if (cursors.Count() == 0) { return; }

            //send the command to work
            KillCursorsRequest request = new KillCursorsRequest(cursors);
            QueryResponse response = database.SendRequest(request) as QueryResponse;
        }