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

Expression not supported: -i.A

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Unknown Unknown
    • 2.21.0
    • None
    • 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?

    Description

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

      Attachments

        Activity

          People

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

            Dates

              Created:
              Updated:
              Resolved: