[CSHARP-4467] document alternatives to MongoDB.Bson.ObjectId.Pack() Created: 24/Dec/22  Updated: 27/Oct/23  Resolved: 18/Jan/23

Status: Closed
Project: C# Driver
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Task Priority: Minor - P4
Reporter: Rachelle Palmer Assignee: Robert Stam
Resolution: Gone away Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

User request:
"Packing a new ObjectId with MongoDB.Bson.ObjectId.Pack() or ObjectId constructor is deprecated in C#, and apparently will be removed in later releases.

I would like to see more information about it in the documentation, and also an alternative solution to it. Thank you!"



 Comments   
Comment by PM Bot [ 18/Jan/23 ]

There hasn't been any recent activity on this ticket, so we're resolving it. Thanks for reaching out! Please feel free to comment on this if you're able to provide more information.

Comment by Robert Stam [ 03/Jan/23 ]

Pack is deprecated because the format of an ObjectId has changed in the BSON specification:

https://www.mongodb.com/docs/manual/reference/method/ObjectId/

An ObjectId is now composed of a timestamp, random value and increment. It is no longer composed of a timestamp, machine, pid and increment values as it once was.

If you want to create an ObjectId in a non-standard way the remaining non-deprecated way to do that is to use the ObjectId constructor that takes a 12-byte array as as argument.

Generated at Wed Feb 07 21:48:19 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.