Convert .NET Guid to MongoDB ObjectID

后端 未结 4 1506
臣服心动
臣服心动 2021-02-03 22:11

How can I convert a .NET GUID to a MongoDB ObjectID (in C#). Also, can I convert it back again to the same GUID from the ObjectID?

4条回答
  •  无人及你
    2021-02-03 22:45

    although not a direct answer keep in mind that there is no.requirement that _id be an ObjectID --- only that it be unique.

    any valid type can be set for _I'd including an embedded object or a . you should be fine (barring any uniqueness violations) using a GUID for _id; in fact, ObjectID is really just a custom GUID.

提交回复
热议问题