Hello there. I'm new to MongoDB and C#, so please don't frown when this is a stupid question. But I'm unable to access documents in the web client where the value for the _id column (property?) was generated from a C# Guid.
Here's my (simplified) C# class:
public class MyClass
{
[BsonId]
public Guid MyId {get; set; }
public string MyPropertyA { get; set; }
}
Now when I store a document:
var myClassObj = new MyClass
{
MyId = Guid.NewGuid(), // Let's assume it is "C56A4180-65AA-42EC-A945-5FD21DEC0538"
MyPropertyA = "Foo"
}
await mongoClient.SaveDocument(myClassObj.ToBsonDocument());
This is what ends up in the mongo database (retrieved with mongo cli):
Hello there. I'm new to MongoDB and C#, so please don't frown when this is a stupid question. But I'm unable to access documents in the web client where the value for the _id column (property?) was generated from a C# Guid.
Here's my (simplified) C# class:
Now when I store a document:
var myClassObj = new MyClass { MyId = Guid.NewGuid(), // Let's assume it is "C56A4180-65AA-42EC-A945-5FD21DEC0538" MyPropertyA = "Foo" } await mongoClient.SaveDocument(myClassObj.ToBsonDocument()); This is what ends up in the mongo database (retrieved with mongo cli):
{ "_id" : BinData(3,"gEFqxapl7EKpRV/SHewFOA=="), "MyPropertyA": "Foo" }