Skip to content

Commit 56d9ab1

Browse files
author
Hugo Bonacci
committed
Changed the way that a query argument with a modifier was added
1 parent 0ea2f6a commit 56d9ab1

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

Query/MongoQuery.cs

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -51,18 +51,15 @@ public MongoQuery(MongoDatabase database, string collection)
5151
/// </summary>
5252
public MongoQuery AppendParameter(string field, string modifier, object value) {
5353

54-
//make sure there is a field available
55-
if (!(this._Parameters[field] is BsonDocument)) {
56-
this._Parameters[field] = new BsonDocument();
54+
//if using a modifier, set this as a document
55+
if (modifier is string) {
56+
BsonDocument parameters = new BsonDocument();
57+
parameters[modifier] = value;
58+
this._Parameters[field] = parameters;
5759
}
58-
59-
//if there isn't a modifier, just set it as the value
60-
if (modifier == null) {
61-
this._Parameters[field] = value;
62-
}
63-
//otherwise, set the modifier key and value inside of the document
60+
//otherwise, just assign the value
6461
else {
65-
(this._Parameters[field] as BsonDocument)[modifier] = value;
62+
this._Parameters[field] = value;
6663
}
6764

6865
//return the query to use

0 commit comments

Comments
 (0)