Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add param to not throw if a command fails.

  • Loading branch information...
commit a1608d811f4c2de34eebc6ec22275e5cbeca14f7 1 parent f57a416
Steve Wagner lanwin authored
Showing with 17 additions and 1 deletion.
  1. +17 −1 source/MongoDB/Connections/Connection.cs
18 source/MongoDB/Connections/Connection.cs
View
@@ -247,11 +247,27 @@ public Document SendCommand(ISerializationFactory factory, string database, Type
public T SendCommand<T>(ISerializationFactory factory, string database, Type rootType, object command)
where T : CommandResultBase
{
+ return SendCommand<T>(factory, database, rootType, command, true);
+ }
+
+ /// <summary>
+ /// Sends the command.
+ /// </summary>
+ /// <typeparam name="T"></typeparam>
+ /// <param name="factory">The factory.</param>
+ /// <param name="database">The database.</param>
+ /// <param name="rootType">Type of serialization root.</param>
+ /// <param name="command">The spec.</param>
+ /// <param name="throw">if set to <c>true</c> [@throw].</param>
+ /// <returns></returns>
+ public T SendCommand<T>(ISerializationFactory factory, string database, Type rootType, object command, bool @throw)
+ where T : CommandResultBase
+ {
AuthenticateIfRequired(database);
var result = SendCommandCore<T>(factory, database, rootType, command);
- if(!result.Success)
+ if(@throw && !result.Success)
throw new MongoCommandException(result.ErrorMessage, null, null);
return result;
Please sign in to comment.
Something went wrong with that request. Please try again.