@@ -120,10 +120,26 @@ members and the corresponding ``BsonBinaryData`` subtypes:
120120 * - ``Unspecified``
121121 - N/A
122122
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:
124136
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);
127143
128144The following sections describe the ways in which you can configure GUID representation
129145in your application.
@@ -218,35 +234,6 @@ method:
218234 var objectSerializer = new ObjectSerializer(objectDiscriminatorConvention, GuidRepresentation.Standard);
219235 BsonSerializer.RegisterSerializer(objectSerializer);
220236
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-
250237Additional Information
251238----------------------
252239
@@ -257,5 +244,4 @@ guide, see the following API documentation:
257244- `BsonGuidRepresentation <{+new-api-root+}/MongoDB.Bson/MongoDB.Bson.Serialization.Attributes.BsonGuidRepresentationAttribute.html>`__
258245- `GuidSerializer <{+new-api-root+}/MongoDB.Bson/MongoDB.Bson.Serialization.Serializers.GuidSerializer.html>`__
259246- `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