当前位置: 首页>>代码示例>>C#>>正文


C# MongoDatabase.SendRequest方法代码示例

本文整理汇总了C#中MongoDatabase.SendRequest方法的典型用法代码示例。如果您正苦于以下问题:C# MongoDatabase.SendRequest方法的具体用法?C# MongoDatabase.SendRequest怎么用?C# MongoDatabase.SendRequest使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MongoDatabase的用法示例。


在下文中一共展示了MongoDatabase.SendRequest方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: RunCommand

        /// <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;
        }
开发者ID:hugoware,项目名称:CSMongo,代码行数:22,代码来源:MongoDatabaseCommands.cs

示例2: KillCursors

        /// <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;
        }
开发者ID:hugoware,项目名称:CSMongo,代码行数:12,代码来源:MongoDatabaseCommands.cs


注:本文中的MongoDatabase.SendRequest方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。