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

Decimal trancation issuewhen running the aggegate

    • Type: Icon: Bug Bug
    • Resolution: Duplicate
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • None

      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.

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

              Created:
              Updated:
              Resolved: