@@ -120,10 +120,26 @@ members and the corresponding ``BsonBinaryData`` subtypes:
120
120
* - ``Unspecified``
121
121
- N/A
122
122
123
- .. note::
123
+ The ``CSharpLegacy``, ``JavaLegacy``, and ``PythonLegacy`` GUID
124
+ representations are all equivalent to ``BsonBinaryData`` subtype 3, but
125
+ use different byte orders.
126
+
127
+ .. _csharp-guid-query:
128
+
129
+ .. note:: Construct Legacy GUIDs
130
+
131
+ To construct legacy (subtype 3) GUID values, you must use the
132
+ ``BsonBinaryData()`` constructor to explicitly specify the legacy GUID
133
+ type by passing the ``GuidRepresentation.CSharpLegacy`` parameter. The
134
+ following code demonstrates how to create a legacy GUID to use in a
135
+ query filter:
124
136
125
- The ``CSharpLegacy``, ``JavaLegacy``, and ``PythonLegacy`` GUID representations are
126
- all equivalent to ``BsonBinaryData`` subtype 3, but use different byte orders.
137
+ .. code-block:: csharp
138
+ :emphasize-lines: 2
139
+
140
+ var guid = new Guid("00112233-4455-6677-8899-aabbccddeeff");
141
+ var legacyGuid = new BsonBinaryData(guid, GuidRepresentation.CSharpLegacy);
142
+ var filter = new BsonDocument("legacyGuidField", legacyGuid);
127
143
128
144
The following sections describe the ways in which you can configure GUID representation
129
145
in your application.
@@ -218,35 +234,6 @@ method:
218
234
var objectSerializer = new ObjectSerializer(objectDiscriminatorConvention, GuidRepresentation.Standard);
219
235
BsonSerializer.RegisterSerializer(objectSerializer);
220
236
221
- .. _csharp-guid-query:
222
-
223
- Query GUIDs
224
- -----------
225
-
226
- You can query on standard (subtype 4) GUID values by using the
227
- ``BsonValue.Create()`` method. First, create a GUID value by using the
228
- ``Guid()`` constructor. Then, pass the GUID to the
229
- ``BsonValue.Create()`` method to instantiate a ``BsonValue`` to use in
230
- your query filter, as shown in the following code:
231
-
232
- .. code-block:: csharp
233
-
234
- var guid = new Guid("33221100-5544-7766-8899-aabbccddeeff");
235
- var filter = new BsonDocument("guidField", BsonValue.Create(guid));
236
-
237
- To query on legacy (subtype 3) GUID values, you must use the
238
- ``BsonBinaryData()`` constructor to explicitly specify the legacy GUID
239
- type by passing the ``GuidRepresentation.CSharpLegacy`` parameter. The
240
- following code demonstrates how to create a legacy GUID to use in a
241
- query filter:
242
-
243
- .. code-block:: csharp
244
- :emphasize-lines: 2
245
-
246
- var guid = new Guid("00112233-4455-6677-8899-aabbccddeeff");
247
- var legacyGuid = new BsonBinaryData(guid, GuidRepresentation.CSharpLegacy);
248
- var filter = new BsonDocument("legacyGuidField", legacyGuid);
249
-
250
237
Additional Information
251
238
----------------------
252
239
@@ -257,5 +244,4 @@ guide, see the following API documentation:
257
244
- `BsonGuidRepresentation <{+new-api-root+}/MongoDB.Bson/MongoDB.Bson.Serialization.Attributes.BsonGuidRepresentationAttribute.html>`__
258
245
- `GuidSerializer <{+new-api-root+}/MongoDB.Bson/MongoDB.Bson.Serialization.Serializers.GuidSerializer.html>`__
259
246
- `ObjectSerializer <{+new-api-root+}/MongoDB.Bson/MongoDB.Bson.Serialization.Serializers.ObjectSerializer.html>`__
260
- - `GuidRepresentation
261
- <{+new-api-root+}/MongoDB.Bson/MongoDB.Bson.GuidRepresentation.html>`__
247
+ - `GuidRepresentation <{+new-api-root+}/MongoDB.Bson/MongoDB.Bson.GuidRepresentation.html>`__
0 commit comments