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

Expression not supported: Math.Round

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Unknown Unknown
    • 2.21.0
    • Affects Version/s: None
    • Component/s: None
    • None
    • Fully Compatible
    • Not Needed
    • Hide

      1. What would you like to communicate to the user about this feature?
      2. Would you like the user to see examples of the syntax and/or executable code and its output?
      3. Which versions of the driver/connector does this apply to?

      Show
      1. What would you like to communicate to the user about this feature? 2. Would you like the user to see examples of the syntax and/or executable code and its output? 3. Which versions of the driver/connector does this apply to?

      Usage of Math.Round throws ExpressionNotSupportedException exception. Here is the minimal code to reproduce the issue:

       

      public class MathRoundTests : Linq3IntegrationTest
      {
          [Fact]
          public void Math_round()
          {
              var collection = CreateCollection();
      
              var query = collection.AsQueryable()
                  .Where(i => Math.Round(i.A) == 10);
      
              var results = query.ToList();
      
              results.Should().OnlyContain(i => Math.Round(i.A) == 10);
          }
      
          private IMongoCollection<Data> CreateCollection()
          {
              var collection = GetCollection<Data>("test");
              CreateCollection(
                  collection,
                  new Data { A = 10.234 },
                  new Data { A = 9.6 },
                  new Data { A = 9.2 },
                  new Data { A = 5.42 });
              return collection;
          }
      
          private class Data
          {
              public double A { get; set; }
          }
      } 

            Assignee:
            oleksandr.poliakov@mongodb.com Oleksandr Poliakov
            Reporter:
            oleksandr.poliakov@mongodb.com Oleksandr Poliakov
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: