How to use MongoDB.Bson.ObjectId as Id
See original GitHub issueHow can I use MongoDB.Bson.ObjectId
as an Entity Id instead of a string?
I tried this:
public class Query : IEntity { [BsonId, ObjectId] public ObjectId Id { get; set; } }
but this returns null:
var query = MongoDB.Entities.DB.Queryable<Query>().FirstOrDefault(x => x.Id == queryID);
This is possible in the offical MongoDB.Driver, please implement it…
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:6 (4 by maintainers)
Top Results From Across the Web
ObjectId() — MongoDB Manual
For timestamp and counter values, the most significant bytes appear first in the byte sequence (big-endian). This is unlike other BSON values, where...
Read more >MongoDB\BSON\ObjectId - Manual
In MongoDB, each document stored in a collection requires a unique _id field that acts as a primary key. If an inserted document...
Read more >Quick Start: BSON Data Types - ObjectId
ObjectId is one data type that is part of the BSON Specification that MongoDB uses for data storage. It is a binary representation...
Read more >ObjectId — MongoDB Manual
ObjectId is a 12-byte BSON type, constructed using: ... In MongoDB, documents stored in a collection require a unique _id field that acts...
Read more >What Is Objectid in Mongodb and How to Generate ...
MongoDB uses ObjectIds as the default value of _id field of each document, which is generated during the creation of any document. Object...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
migrating an existing project will be a pain either way 😃 some compromises had to be made with the flexibility to support the features of this library.
here’s an example: