I use FindAndModifyto modify a document.
The document has a type User, and the element to change is called web:
var users = _db.GetCollection<User>(UserCollectionName);
var userQuery = Query.EQ("user", "testuser");
var findAndModifyResult = users.FindAndModify(
new FindAndModifyArgs()
{
Query = userQuery,
Update = Update.Set("web", "testweb")
});
var user = findAndModifyResult.GetModifiedDocumentAs<User>();
user = users.FindOne(userQuery);
GetModifiedDocumentAs()does not return the modified instance, user.webit still has the same meaning as before the update.
When I query Userwith FindOne(), I see the changed value.
Is there anything I need to take care to FindAndModify()return the changed document?
source
share