mongo-expresss / mongo-express

5 stars 11 forks source link

Accessing documents with BinData as value for `_id` #10

Open sekhriv opened 7 years ago

sekhriv commented 7 years ago

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):

{ "_id" : BinData(3,"gEFqxapl7EKpRV/SHewFOA=="), "MyPropertyA": "Foo" }

midosharma commented 7 years ago

Hey It is working now, some one fixed it.