Skip to content

Commit ada9b5f

Browse files
committed
RB restructure
1 parent 96dff17 commit ada9b5f

File tree

2 files changed

+22
-35
lines changed

2 files changed

+22
-35
lines changed

source/fundamentals/serialization/guid-serialization.txt

Lines changed: 20 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -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

128144
The following sections describe the ways in which you can configure GUID representation
129145
in 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-
250237
Additional 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>`__

source/upgrade/v3.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,8 @@ Version 3.0 Breaking Changes
114114
- The ``BsonBinaryData(Guid)`` constructor has been removed. To
115115
construct a ``BsonBinaryData`` object from a GUID, use the
116116
``BsonBinaryData.Create(Guid, GuidRepresentation)`` constructor. To
117-
view an example, see :ref:`csharp-guid-query` in the GUIDs guide.
117+
view an example, see the :ref:`Construct Legacy GUIDs
118+
<csharp-guid-query>` note in the GUID Serialization guide.
118119
- The ``BsonBinaryData.GuidRepresentation`` property has been removed.
119120
- You can call the ``BsonBinaryData.ToGuid()`` method only on ``BsonBinaryData``
120121
objects of subtype 4. If the object has any other subtype, you must call the

0 commit comments

Comments
 (0)