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

Truncation resulted in data loss when Sum (Linq)

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 2.8.0, 2.8.1
    • Component/s: Linq
    • Labels:
      None

      Good morning,

      I'm face with this issue:

      I have property Total in my MongoDB stored as Double type.

      I get all Total as IQueryable<decimal> in my c# code and I call Sum but I received this error:

      Truncation resulted in data loss

      Code is:

      var foo = bar.GetCollection<MyClass>("MyCollectionName").AsQueryable()
      .Where(x => x.MyProperty == 10)
      .Sum(x => x.Total);

       This not works

       

      This problem there is not if I use IEnumerable:

      var foo = bar.GetCollection<MyClass>("MyCollectionName").AsQueryable()
      .Where(x => x.MyProperty == 10).AsEnumerable()
      .Sum(x => x.Total);

      This works

       

            Assignee:
            wan.bachtiar@mongodb.com Wan Bachtiar
            Reporter:
            mini-dev-1 Mini Dev
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: