本文整理汇总了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;
}
示例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;
}