Support static String.Compare method

XMLWordPrintableJSON

    • Type: New Feature
    • Resolution: Done
    • Priority: Unknown
    • 3.6.0
    • Affects Version/s: None
    • Component/s: None
    • None
    • 🔵 Done
    • Fully Compatible
    • Dotnet Drivers
    • 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?
    • None
    • None
    • None
    • None
    • None
    • None

      Driver failed to translate an expression containing string.Compare call by throwing 
      ExpressionNotSupportedException.
      Code to reproduce the problem:

      [Fact]
      public void String_Compare_should_work()
      {
          var collection = Fixture.Collection;
      
          var queryable = collection.AsQueryable()
              .Where(d => string.Compare(d.Key, "a4e48b55-0519-4ab3-b6b9-7c532fc65b56") > 0);
      
          var stages = Translate(collection, queryable);
          AssertStages(stages, "{ $match: { _id: { $gt: 'a4e48b55-0519-4ab3-b6b9-7c532fc65b56' }, }, }");
      
          var result = queryable.ToList();
          result.Should().HaveCount(1);
      }
      
      public class C
      {
          public string Key { get; set; }
      }
      
      public sealed class ClassFixture : MongoCollectionFixture<C>
      {
          protected override IEnumerable<C> InitialData =>
          [
              new C { Key = "1b2bc240-ec2a-4a17-8790-8407e3bbb847"},
              new C { Key = "a4e48b55-0519-4ab3-b6b9-7c532fc65b56"},
              new C { Key = "9ff72c5d-189e-4511-b7ad-3f83489e4ea4"},
              new C { Key = "d78ca958-abac-46cd-94a7-fbf7a2ba683d"},
          ];
      } 

            Assignee:
            Robert Stam
            Reporter:
            Oleksandr Poliakov
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: