Mongo C# Driver and ObjectID JSON String Format -
is possible force jsonwritersettings
output objectid
{ "id" : "522100a417b86c8254fd4a06" }
instead of
{ "_id" : { "$oid" : "522100a417b86c8254fd4a06" }
i know write own parser, sake of code maintenance, find away possibly override mongo jsonwritersettings
.
if possible, classes/interfaces should override?
if you're ok using mongodb c# attributes or mapper, can this:
public class order { [bsonid] [bsonrepresentation(bsontype.objectid)] public string id { get; set; } }
that way, can refer type string (including serialization), when mongodb serializes it, etc., it's internally treated objectid. here's using class map technique:
bsonclassmap.registerclassmap<order>(cm => { cm.automap(); cm.setidmember(cm.getmembermap(c => c.id); cm.getmembermap(c => c.id) .setrepresentation(bsontype.objectid); });
Comments
Post a Comment