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

Expression not supported: -i.A

    • 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 unary negation operator is throwing ExpressionNotSupportedException exception. Code to reproduce:

       

      public class MathNegationTests : Linq3IntegrationTest
      {
          [Fact]
          public void Math_negation()
          {
              var collection = CreateCollection();
      
              var query = collection.AsQueryable()
                  .Where(i => -i.A == 10);
      
              var results = query.ToList();
      
              results.Should().OnlyContain(i => -i.A == 10);
          }
      
          private IMongoCollection<Data> CreateCollection()
          {
              var collection = GetCollection<Data>("test");
              CreateCollection(
                  collection,
                  new Data { A = -10 },
                  new Data { A = 5 });
              return collection;
          }
      
          private class Data
          {
              public int 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: