[CSHARP-4696] Expression not supported: Math.Round Created: 27/Jun/23  Updated: 28/Oct/23  Resolved: 04/Jul/23

Status: Closed
Project: C# Driver
Component/s: None
Affects Version/s: None
Fix Version/s: 2.21.0

Type: Bug Priority: Unknown
Reporter: Oleksandr Poliakov Assignee: Oleksandr Poliakov
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Backwards Compatibility: Fully Compatible
Documentation Changes: Not Needed
Documentation Changes Summary:

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?


 Description   

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; }
    }
} 



 Comments   
Comment by Githook User [ 04/Jul/23 ]

Author:

{'name': 'Oleksandr Poliakov', 'email': '31327136+sanych-sun@users.noreply.github.com', 'username': 'sanych-sun'}

Message: CSHARP-4696: Expression not supported: Math.Round (#1124)
Branch: master
https://github.com/mongodb/mongo-csharp-driver/commit/0dd40f6325ae1239f1ad7c2479364209834924ba

Generated at Wed Feb 07 21:49:04 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.