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

Linux /.Net 7 / mongodb.driver.core.2.21.0 - ExpressionNotSupportedException

    • Type: Icon: Bug Bug
    • Resolution: Works as Designed
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 2.21.0
    • Component/s: LINQ3
    • 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?

      Mongodb Standalone server

      Summary

      Hello everyone,

      I encountered an error when executing the query illustrated below.

      varcollection = _mongoDb.GetCollection<MyCollection>();
      var data = collection.AsQueryable().Any(x=>x.Identifier==newGuid("72E32DEE-6D98-427E-8863-263414DACC8D"));
      The error is:

      Exception has occurred: CLR/MongoDB.Driver.Linq.ExpressionNotSupportedException
      Exception thrown: 'MongoDB.Driver.Linq.ExpressionNotSupportedException' in MongoDB.Driver.dll: 'Expression not supported: (x.Identifier == 72e32dee-6d98-427e-8863-263414dacc8d).'
         at MongoDB.Driver.Linq.Linq3Implementation.Translators.ExpressionToFilterTranslators.MethodTranslators.StringExpressionToRegexFilterTranslator.TranslateComparisonExpression(TranslationContext context, Expression expression, Expression leftExpression, AstComparisonFilterOperator comparisonOperator, Expression rightExpression)

       

      From my understanding, it seems to be related to System.Linq.Queryable while using the MongoDB.Driver version 2.21 in .NET 7.

      Does anyone have insights or solutions regarding this issue?

      Your assistance is greatly appreciated. Thank you!

      How to Reproduce

      varcollection = _mongoDb.GetCollection<MyCollection>();
      var data = collection.AsQueryable().Any(x=>x.Identifier==newGuid("72E32DEE-6D98-427E-8863-263414DACC8D"));
       

            Assignee:
            boris.dogadov@mongodb.com Boris Dogadov
            Reporter:
            michele.lauriola@gmail.com Michele Lauriola
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: