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

Exception in .Where() matching Id

    XMLWordPrintableJSON

Details

    • Icon: Question Question
    • Resolution: Works as Designed
    • Icon: Major - P3 Major - P3
    • None
    • 2.18.0
    • LINQ3
    • None

    Description

      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!

      Attachments

        Activity

          People

            robert@mongodb.com Robert Stam
            dimitri.kroo@baramundi.com Dimitri Kroo
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: