Skip to content

Instantly share code, notes, and snippets.

@jonnii
Created October 10, 2012 19:39
Show Gist options
  • Save jonnii/3867914 to your computer and use it in GitHub Desktop.
Save jonnii/3867914 to your computer and use it in GitHub Desktop.
updae query
public class UpdateJobIsPinned : IUpdate<Job, bool>
{
public UpdateJobIsPinned(string id, bool isPinned)
{
Id = id;
IsPinned = isPinned;
}
public string Id { get; private set; }
public bool IsPinned { get; private set; }
public bool Execute(MongoCollection<Job> collection)
{
var query = Query.EQ("_id", new BsonObjectId(Id));
var update = Update.Set("IsPinned", IsPinned);
var result = collection.Update(
query,
update,
SafeMode.True);
return result.DocumentsAffected > 0;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment