Exception in .Where() matching Id

XMLWordPrintableJSON

    • Type: Question
    • Resolution: Works as Designed
    • Priority: Major - P3
    • None
    • Affects Version/s: 2.18.0
    • Component/s: LINQ3
    • None
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      Summary

      Hi,

      I'm getting an exception with simple filtering on ObjectId represented as string inside a C# class.

      Exception:
      MongoDB.Driver.Linq.ExpressionNotSupportedException: 'Expression not supported: x.SomeId in (x.SomeId == "634cf4c86a1bde31017xxxxx") because field "SomeId" is not represented as a string.'

      Call:
      someCollection.AsQueryable(options)
      .Where(x => x.SomeId == "634cf4c86a1bde31017xxxxx");

      Property in the class:
      [BsonRepresentation(MongoDB.Bson.BsonType.ObjectId)]
      public string SomeId { get; set; }

      It works with LinqProvider V2.

      Please provide the version of the driver. If applicable, please provide the MongoDB server version and topology (standalone, replica set, or sharded cluster).

      2.18.0

      How to Reproduce

      Call AsQueryable with Where() filtering on objectId as string property inside a class.

      Thank you!

            Assignee:
            Robert Stam (Inactive)
            Reporter:
            Dimitri Kroo
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: