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

Truncation resulted in data loss.

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Cannot Reproduce
    • Icon: Major - P3 Major - P3
    • None
    • 2.7.0
    • Serialization
    • None
    • .NET Core 2.1

    Description

      When running an aggregation through LINQ using IMongoQueryable I get this error when mapping to a decimal.

      My mapping looks like this:

      BsonClassMap.RegisterClassMap<SkuToOrder>(x =>
      {
          x.AutoMap();
          x.MapProperty(prop => prop.CurrentStock).SetSerializer(new DecimalSerializer(BsonType.Decimal128, new RepresentationConverter(false, true)));
          x.MapProperty(prop => prop.NeededStock).SetSerializer(new DecimalSerializer(BsonType.Decimal128, new RepresentationConverter(false, true)));
          x.MapProperty(prop => prop.StockToOrder).SetSerializer(new DecimalSerializer(BsonType.Decimal128, new RepresentationConverter(false, true)));
          x.SetIgnoreExtraElements(true);
      });
      

      Here's an example model which generates this error:

      { 
          "Sku" : "0242", 
          "Description" : "xxx", 
          "CurrentStock" : NumberDecimal("0"), 
          "NeededStock" : NumberDecimal("0.6666666666666666666666666666666667"), 
          "StockToOrder" : NumberDecimal("0.6666666666666666666666666666666667")
      }
      

       

      Attachments

        Activity

          People

            robert@mongodb.com Robert Stam
            brechtvhb Brecht Vanhaesebrouck
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: