How to use decimal type in MongoDB

前端 未结 4 712
终归单人心
终归单人心 2020-11-29 11:07

How can I store decimals in MongoDB using the standard C# driver? It seems that all decimals are stored inside the database as strings.

4条回答
  •  忘掉有多难
    2020-11-29 11:46

    I recently ran in to this problem. I solved it by simply annotating my object like this:

    [BsonRepresentation(BsonType.Decimal128)]
    public decimal Price {get; set;}
    

提交回复
热议问题