Created
October 10, 2012 19:39
-
-
Save jonnii/3867914 to your computer and use it in GitHub Desktop.
updae query
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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