Permalink
Browse files

Use SendCommand which dose not throws an exception on find and modify.

  • Loading branch information...
1 parent a1608d8 commit 3a3d3c4cd17f155a20e4010add69c145cef22ed2 @lanwin lanwin committed Oct 20, 2010
Showing with 11 additions and 18 deletions.
  1. +11 −18 source/MongoDB/MongoCollection_1.cs
@@ -228,9 +228,7 @@ public T FindAndModify(object document, object spec, object sort, bool returnNew
/// <returns>A <see cref="Document"/></returns>
public T FindAndModify(object document, object spec, object sort, object fields, bool remove, bool returnNew, bool upsert)
{
- try
- {
- var command = new Document
+ var command = new Document
{
{"findandmodify", Name},
{"query", spec},
@@ -240,23 +238,18 @@ public T FindAndModify(object document, object spec, object sort, object fields,
{"upsert", upsert}
};
- if(sort != null)
- command.Add("sort", sort);
- if(fields != null)
- command.Add("fields", fields);
+ if(sort != null)
+ command.Add("sort", sort);
+ if(fields != null)
+ command.Add("fields", fields);
- var response = _connection.SendCommand<FindAndModifyResult<T>>(_configuration.SerializationFactory,
- DatabaseName,
- typeof(T),
- command);
+ var response = _connection.SendCommand<FindAndModifyResult<T>>(_configuration.SerializationFactory,
+ DatabaseName,
+ typeof(T),
+ command,
+ false);
- return response.Value;
- }
- catch(MongoCommandException)
- {
- // This is when there is no document to operate on
- return null;
- }
+ return response.Value;
}
/// <summary>

0 comments on commit 3a3d3c4

Please sign in to comment.