Support static String.Compare method

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Unresolved
    • Priority: Unknown
    • None
    • Affects Version/s: None
    • Component/s: None
    • None
    • None
    • Dotnet Drivers
    • 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: