score:6

Accepted answer

did you try set allowtruncation=true for your properities in city class?

public class city
{
    [bsonid]
    [bsonrepresentation(bsontype.int, allowtruncation=true)]
    public string id { get; set; }
    [bsonrepresentation(bsontype.int, allowtruncation=true)]
    public int value { get; set; }        
}

how do i set the serialization options for the geo values using the official 10gen c# driver?

score:7

you typically don't want your model to know or care how it's being stored, so peppering it with mongodb.bson attributes is not ideal. you can configure how mongodb.driver should read and store decimals with this config instead.

bsonserializer.registerserializer(
  typeof(decimal),
   new decimalserializer(bsontype.double,
   new representationconverter(
     true, // allow overflow, return decimal.minvalue or decimal.maxvalue instead
     true //allow truncation
    ))
 );

source


Related Query

More Query from same tag