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

Truncation resulted in data loss.

    • Type: Icon: Bug Bug
    • Resolution: Cannot Reproduce
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 2.7.0
    • Component/s: Serialization
    • Labels:
      None
    • Environment:
      .NET Core 2.1

      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")
      }
      

       

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

              Created:
              Updated:
              Resolved: