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

Decimal trancation issuewhen running the aggegate

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: Major - P3 Major - P3
    • None
    • None
    • None
    • None

    Description

      Due to space limitation I attached all code as a file.
      Consider code sample 1 and 2. They do exactly the same aggregation. They output result using the same LiabilitySetTotals class. This class has few decimal properties. In the DB those values are double. Therefore those properties have [BsonRepresentation(BsonType.Double, AllowTruncation = true)] attribute.

      When I use "inline" style of building group expression for aggregation using BsonDocument, output result as a document and convert it to my LiabilitySetTotals, all works fine.

      But when I use Linq to build group expression using the LiabilitySetTotals directly, I get an error:
      System.FormatException : An error occurred while deserializing the TotalAmount property of class ...LiabilitySetTotals: Truncation resulted in data loss.

      It looks like aggregation does not pay attention to BsonRepresentation attribute.

      Attachments

        Activity

          People

            Unassigned Unassigned
            lennygran Lenny Granovsky
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: