Summary
When making a linq query, where you try to match a value that is a string in c# but has the attribute [BsonRepresentation(BsonType.ObjectId)] against an array of string, then you get the error: "Expression not supported: (fId == f.Id) because the two arguments are serialized differently" It was not an issue before version 3.2.0
How to Reproduce
If you have the model
public class Test { [BsonId] [BsonRepresentation(BsonType.ObjectId)] public string? Id { get; set; } }
And you then run a find like:
var client = new MongoClient(); var mongoDatabase = client.GetDatabase("Test"); var collection = mongoDatabase.GetCollection<Test>("Test"); var array = new string[] { "67b6f6aea9e81c51180d8668" }; await collection.Find(t => array.Any(id => id == t.Id)).ToListAsync();
You will get the error:
Expression not supported: (id == t.Id) because the two arguments are serialized differently.