Uploaded image for project: 'C# Driver'
  1. C# Driver
  2. CSHARP-2198

Update.Set Decimal

    • Type: Icon: Task Task
    • Resolution: Works as Designed
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 2.5
    • Component/s: None
    • Environment:
      .netcore 2, linux
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      public Task SetPrice(Guid id, decimal price) {
      MongoClientSettings settings = MongoClientSettings.FromUrl(new MongoUrl(Environment.GetEnvironmentVariable("DB")));
      var mongoConnection = new MongoDB.Driver.MongoClient(settings);
      var collection = mongoConnection.Database.GetCollection<BsonDocument>("test");
      return collection.UpdateOneAsync(Builders<BsonDocument>.Filter.Eq("_id", id), Builders<BsonDocument>.Update.Set("price", price), new UpdateOptions {IsUpsert = true});
      }
      

      as a result, I get

      { "_id" : NUUID("ecefa3d7-8553-446a-ac46-6f565d05d33a"), *"price" : "22.3"* }

      But I expect to get

      { "_id" : NUUID("ecefa3d7-8553-446a-ac46-6f565d05d33a"), "price" : *NumberDecimal("22.3")* }

            Assignee:
            robert@mongodb.com Robert Stam
            Reporter:
            otemnov Oleg Temnov
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: