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

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -