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

ExpressionNotSupportedException for string.IsNullOrWhitespace after upgrade

    • Type: Icon: New Feature New Feature
    • Resolution: Done
    • Priority: Icon: Unknown Unknown
    • 2.21.0
    • Affects Version/s: None
    • Component/s: None
    • None
    • 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?

      Summary

      I am running MongoDb 6.0.6

      When upgrading from Mongodbdriver 2.18 to 2.19.2 several queries I run begin to fail with the ExpressionNotSupportedException.

      How to Reproduce

       
      Query on any string field e.g
       
      _profileDataCollection.Find(model.GetFilter())
      .Project(x => new ProfileReportModel {
      Id = x.Id,
      Bio = !string.IsNullOrWhiteSpace(x.Bio),
      CurrentStatus = !string.IsNullOrWhiteSpace(x.CurrentStatus)
       
      In this example Bio and CurrentStatus are string fields
       
      Downgrading the connection to LinqProvider.V2 fixes the issue:
       
      var clientSettings = MongoClientSettings.FromConnectionString(Configuration.GetConnectionString(nameof(StudentProfile)));
      clientSettings.LinqProvider = LinqProvider.V2;
      var client = new MongoClient(clientSettings);

      It appears to be similar to this issue:
      https://www.mongodb.com/community/forums/t/issue-with-2-18-to-2-19-nuget-upgrade-of-mongodb-c-driver/211894
       

            Assignee:
            robert@mongodb.com Robert Stam
            Reporter:
            john.staveley@myglobalbridge.com John Staveley
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: