I'm running version 2.06 of Mongodb and version (1.5) of the C# driver supplied by 10Gen.
Each of my entities has an Id property setup as such...
[BsonId(IdGenerator = typeof(GuidGenerator))]
public Guid Id { get; set; }
The Id field is stored as Binary - 3:UuidLegacy. Because of how it is stored when I call ToJson() on an entity it returns the following javascript object for the Id.
_id : Object
$binary: "some values here"
$type: "03"
This is obviously because the data is being stored as Binary = 3:UuidLegacy. This make sense.
I want to use the actual Guid in my Javascript code. How efficient would it be for MongoDB if I made my Id properties look like the following?
[BsonId(IdGenerator = typeof(GuidGenerator)),MongoDB.Bson.Serialization.Attributes.BsonRepresentation(BsonType.String)]
public Guid Id { get; set; }
This makes mongodb store my Id as a string. But how efficient is this really? I'm guessing the Binary format for my Id is better, but I really need the Guid.
How can I go from Binary - 3:uuidLegacy to the Guid I need in my json?
I guess another thought would be could I just use the $binary value that is sent to me? I use the Id to perform lookups and such as part of my query strings.
Thanks,