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

Compare a field in a BsonDocument to a string doesn't work

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Works as Designed
    • Icon: Unknown Unknown
    • None
    • None
    • LINQ3
    • None

    Description

                 var result = Builders<BsonDocument>.Filter.Where(x => x["_id"] != "");
                  var registry = BsonSerializer.SerializerRegistry;
                  var serializer = registry.GetSerializer<BsonDocument>();
                  var mql = result.Render(serializer, registry, Linq.LinqProvider.V3); 

      The above code triggers exception:

      MongoDB.Driver.Linq.ExpressionNotSupportedException: 'Expression not supported: (x.get_Item("_id") != ).' 

      in this line https://github.com/mongodb/mongo-csharp-driver/blob/88769e2bd8866abd40c274552e38127400a0e731/src/MongoDB.Driver/Linq/Linq3Implementation/Translators/ExpressionToFilterTranslators/ExpressionTranslators/StringExpressionToRegexFilterTranslator.cs#L305.

      Attachments

        Activity

          People

            robert@mongodb.com Robert Stam
            dmitry.lukyanov@mongodb.com Dmitry Lukyanov (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: