You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Another case that deserves mention is enumerations. Enumerations are, by default, represented as their base value. In other words, a plain enum will be represented as an integer value. However, it is possible to instruct the driver to represent an enum as a string.
623
+
Another case that deserves mention is enums. Enums are, by default, represented as their underlying value. In other words, a plain enum will be represented as an integer value. However, it is possible to instruct the driver to represent an enum as a string.
Copy file name to clipboardExpand all lines: Docs/reference/content/reference/driver/crud/writing.md
+21-9Lines changed: 21 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -92,7 +92,7 @@ var result = await collection.DeleteManyAsync(filter);
92
92
93
93
## Find And Modify
94
94
95
-
There are a certain class of operations using the [findAndModify command]({{< docsref "reference/command/findAndModify/" >}}) from the server. This command will perform some operation on the document and return the document either before or after the modification takes place. By default, the document is returned before the modification takes place.
95
+
There are a certain class of operations using the [findAndModify command]({{< docsref "reference/command/findAndModify/" >}}) from the server. This command will perform some operation on the document and return either the original version of the document as it was before the operation, or the new version of the document as it became after the operation. By default, the original version of the document is returned.
96
96
97
97
### FindOneAndDelete
98
98
@@ -102,7 +102,10 @@ A single document can be deleted atomically using [`FindOneAndDeleteAsync`]({{<
Assert(result["FirstName"] =="Jack"); // will be true if a document was found.
124
+
if (result!=null)
125
+
{
126
+
Assert(result["FirstName"] =="Jack");
127
+
}
122
128
```
123
129
124
130
The above will find a document where the `FirstName` is `Jack` and replace it with `replacementDocument`. It will then return the document that was replaced.
@@ -133,7 +139,10 @@ var update = Builders<BsonDocument>.Update.Set("FirstName", "John");
Assert(result["FirstName"] =="Jack"); // will be true if a document was found.
142
+
if (result!=null)
143
+
{
144
+
Assert(result["FirstName"] =="Jack");
145
+
}
137
146
```
138
147
139
148
The above will find a document where the `FirstName` is `Jack` and set its `FirstName` field to `John`. It will then return the document that was replaced.
@@ -145,21 +154,24 @@ Each of the 3 operations has certain options available.
145
154
146
155
#### ReturnDocument
147
156
148
-
For Replacing and Updating, the [`ReturnDocument`]({{< apiref "T_MongoDB_Driver_ReturnDocument" >}}) enum can be provided. It allows you to return the document after the modification has taken place. The default is `Before`.
157
+
For Replacing and Updating, the [`ReturnDocument`]({{< apiref "T_MongoDB_Driver_ReturnDocument" >}}) enum can be provided. It allows you to choose which version of the document to return, either the original version as it was before the operation, or the modified version as it became after the operation.
Assert(result["FirstName"] =="John"); // will be true if a document was found.
171
+
if (result!=null)
172
+
{
173
+
Assert(result["FirstName"] =="John");
174
+
}
163
175
```
164
176
165
177
#### Projection
@@ -168,7 +180,7 @@ A projection can be provided to shape the result. The easiest way to build the p
168
180
169
181
#### Sort
170
182
171
-
Since only a single document is selected, for filters that could result in multiple choices, a sort should be provided and the first document will be selected.
183
+
Since only a single document is selected, for filters that could result in multiple choices, a sort should be provided and the first document in the sort order will be the one modified.
Copy file name to clipboardExpand all lines: Docs/reference/content/upgrading.md
+31-31Lines changed: 31 additions & 31 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -35,10 +35,10 @@ As 2.0 is a major revision, there are some breaking changes when coming from the
35
35
-[CSHARP-979](https://jira.mongodb.org/browse/CSHARP-979): `MongoConnectionStringBuilder` has been removed. Use the documented mongodb connection string format and/or `MongoUrlBuilder`.
36
36
-`MongoServer` is a deprecated class. Anyone using `MongoClient.GetServer()` will encounter a deprecation warning and, depending on how your build is setup, may receive an error. It is still safe to use this API until your code is ported to the new API. *Note that this API requires the use of the [mongocsharpdriver](http://nuget.org/packages/mongocsharpdriver) to include the legacy API.
37
37
-[CSHARP-1043](https://jira.mongodb.org/browse/CSHARP-1043) and [CSHARP-1044](https://jira.mongodb.org/browse/CSHARP-1044): `ReadPreference` and `WriteConcern` were rewritten. These classes are now immutable. Any current application code that sets values on these classes will no longer function. Instead, you should use the With method to alter a `ReadPreference` or `WriteConcern`.
38
-
39
-
``` csharp
40
-
var writeConcern = myCurrentWriteConcern.With(journal: true);
0 commit comments