@@ -40,12 +40,13 @@ The following code block shows an example GUID:
4040.. code-block::
4141 :copyable: false
4242
43- 00112233-4455-6677-8899-aabbccddeeff
43+ 00112233-4455-6677-8899-aabbccddeeff
4444
4545Originally, MongoDB represented GUIDs as ``BsonBinaryData``
4646values of :manual:`subtype 3. </reference/bson-types/#binary-data>`
4747Because subtype 3 didn't standardize the byte order of GUIDs
48- during encoding, different MongoDB drivers encoded GUIDs with different byte orders.
48+ during encoding, different MongoDB drivers encoded GUIDs with different
49+ byte orders.
4950
5051The following tabs show different driver encodings of the preceding GUID to
5152``BsonBinaryData`` subtype 3:
@@ -119,10 +120,26 @@ members and the corresponding ``BsonBinaryData`` subtypes:
119120 * - ``Unspecified``
120121 - N/A
121122
122- .. 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-legacy-construct:
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:
136+
137+ .. code-block:: csharp
138+ :emphasize-lines: 2
123139
124- The ``CSharpLegacy``, ``JavaLegacy``, and ``PythonLegacy`` GUID representations are
125- all equivalent to ``BsonBinaryData`` subtype 3, but use different byte orders.
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);
126143
127144The following sections describe the ways in which you can configure GUID representation
128145in your application.
@@ -227,4 +244,4 @@ guide, see the following API documentation:
227244- `BsonGuidRepresentation <{+new-api-root+}/MongoDB.Bson/MongoDB.Bson.Serialization.Attributes.BsonGuidRepresentationAttribute.html>`__
228245- `GuidSerializer <{+new-api-root+}/MongoDB.Bson/MongoDB.Bson.Serialization.Serializers.GuidSerializer.html>`__
229246- `ObjectSerializer <{+new-api-root+}/MongoDB.Bson/MongoDB.Bson.Serialization.Serializers.ObjectSerializer.html>`__
230- - `GuidRepresentation <{+new-api-root+}/MongoDB.Bson/MongoDB.Bson.GuidRepresentation.html>`__
247+ - `GuidRepresentation <{+new-api-root+}/MongoDB.Bson/MongoDB.Bson.GuidRepresentation.html>`__
0 commit comments